1 # Temporary file name allocation
3 # XXX This tries to be not UNIX specific, but I don't know beans about
4 # how to choose a temp directory or filename on MS-DOS or other
5 # systems so it may have to be changed...
11 # Parameters that the caller may set to override the defaults
17 # Function to calculate the directory to use
23 tempdir
= os
.environ
['TMPDIR']
24 except (KeyError, AttributeError):
25 if os
.name
== 'posix':
26 tempdir
= '/usr/tmp' # XXX Why not /tmp?
28 tempdir
= os
.getcwd() # XXX Is this OK?
32 # Function to calculate a prefix of the filename to use
37 if os
.name
== 'posix':
38 template
= '@' + `os
.getpid()`
+ '.'
40 template
= 'tmp' # XXX might choose a better one
44 # Counter for generating unique names
49 # User-callable function to return a unique temporary file name
57 file = os
.path
.join(dir, pre
+ `counter`
)
58 if not os
.path
.exists(file):