summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-11 19:00:53 (GMT)
committerGuido van Rossum <guido@python.org>1997-04-11 19:00:53 (GMT)
commitf4f756cf55c7ec6534c7d952e2f8af672290aa02 (patch)
tree4a99afce0b13d65fb754352b92db3d3a5e5aae77 /Lib/tempfile.py
parent9e3307494d1e35ad21692a6d275f9719697cc420 (diff)
downloadcpython-f4f756cf55c7ec6534c7d952e2f8af672290aa02.zip
cpython-f4f756cf55c7ec6534c7d952e2f8af672290aa02.tar.gz
cpython-f4f756cf55c7ec6534c7d952e2f8af672290aa02.tar.bz2
(Jack:) Better MacOS support.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 615b803..1acd251 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -24,6 +24,14 @@ def gettempdir():
if os.name == 'nt':
attempdirs.insert(0, 'C:\\TEMP')
attempdirs.insert(0, '\\TEMP')
+ elif os.name == 'mac':
+ import macfs, MACFS
+ try:
+ refnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kTemporaryFolderType, 0)
+ dirname = macfs.FSSpec((refnum, dirid, '')).as_pathname()
+ attempdirs.insert(0, dirname)
+ except macfs.error:
+ pass
if os.environ.has_key('TMPDIR'):
attempdirs.insert(0, os.environ['TMPDIR'])
testfile = gettempprefix() + 'test'
@@ -51,6 +59,8 @@ def gettempprefix():
if template == None:
if os.name == 'posix':
template = '@' + `os.getpid()` + '.'
+ elif os.name == 'mac':
+ template = 'Python-Tmp-'
else:
template = 'tmp' # XXX might choose a better one
return template