]> granicus.if.org Git - python/commitdiff
(Jack:) Better MacOS support.
authorGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 19:00:53 +0000 (19:00 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 19:00:53 +0000 (19:00 +0000)
Lib/tempfile.py

index 615b8033db68cf86b18b3e37b8f349905fdcfd97..1acd251a55f1c0963d5ce28b908a999be8617ea2 100644 (file)
@@ -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