Dirk-Willem van Gulik <[EMAIL PROTECTED]> writes:
> > What's the hangup here? Every Unix I've ever seen, and every Windows
> > version I've ever seen, has a notion of a temporary directory.
>
> Sure - but where it is depends on the unix, wether you are using a
> secure/trusted unix, who you are logged in at, the NFS mounting situation
> du jour. Figuring it out -and- respecting the admin wishes is non trivial.
>
> Often the only reason you want a tmp directory is to create a temp
> file.
(last post of the night...3am...need sleep before i get cranky)
And what if you're looking for a place to put a temporary
sub-directory? Most of the system tempfile() functions actually open
a file, and return some handle to it (for security reasons I'm sure,
an honorable cause). tmpnam() looks like it returns a string, but its
own man page flat out says not to use it, but to use mkstemp() instead
(which returns a file handle or descriptor).
Further, what do you do when you want to control the name of your
temporary file? If you use the functions that allow you to specify a
path template, you must supply the directory as part of that
template. If you use the functions that don't take a template, well,
you've lost control of your naming. The only function I've seen that
pleases me so far is the BSD 4.3 function tempname():
char *tempnam(const char *dir, const char *pfx);
You can specify the prefix, and if you pass NULL for 'dir', the file
is created in the systemwide temporary directory. That's *perfect*.
But it's not portable.
Hmm...what to do...