This has been mentioned before -- at least by myself, perhaps by
others, too -- but the Subversion folks would *really* like to see APR
grow a gimme-a-temp-directory function.
The following is the code portion from Python2.2's tempfile module
whereby a list of places to try as valid temp directories is assembled:
attempdirs = ['/tmp', '/var/tmp', '/usr/tmp', pwd]
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, 1)
dirname = macfs.FSSpec((refnum, dirid, '')).as_pathname()
attempdirs.insert(0, dirname)
except macfs.error:
pass
elif os.name == 'riscos':
scrapdir = os.getenv('Wimp$ScrapDir')
if scrapdir:
attempdirs.insert(0, scrapdir)
for envname in 'TMPDIR', 'TEMP', 'TMP':
if os.environ.has_key(envname):
attempdirs.insert(0, os.environ[envname])
Once the list is built, Python simply starts at the head of the list
(sorry, the "sequence") and checks each path until it finds one in
which it can successfully create, write to (the string "blat", not
that it matters), and remove a file. If no valid directory exists in
the list, an exception is thrown and the caller is just out-of-luck.
I seem to recall that at one point or another, someone was looking
into the Windows side of this functionality (wrowe?). If no one has
any objections, I'd like to try to implement the same algorithm that
Python uses in APR. I don't know how os2 and netware fit into the
picture -- I'd need some guidance there.
As for location and naming, perhaps apr_filepath_temp() would cause
the least disturbance (since all 4 OS-directories under file_io/ have
filepath.c files).
Thoughts?
Volunteers to do this for me? :-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Nov 13 17:29:19 2002