apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmpil...@collab.net
Subject Re: what's the portable temp dir?
Date Wed, 17 Apr 2002 14:49:44 GMT
Stas Bekman <stas@stason.org> writes:

> Any chance APR will handle a portable apr_get_temp_dir function? (which 
> returns the existing writable temp path) which then could be used to 
> create a template wanted by apr_file_mktemp().

Oh, man, would I like to see such a thing.  Subversion has several
instances of needing a temporary directory that's world-writable.

> e.g. perl's CGI.pm which is used on many platforms uses this hardcoded 
> array where it then searches for the first writable directory (at 
> compile time)
> $SL = $CGI::SL;
> my ($vol) = $MAC ? MacPerl::Volumes() =~ /:(.*)/ : "";
>      @TEMP=("${SL}usr${SL}tmp","${SL}var${SL}tmp",
> 	   "C:${SL}temp","${SL}tmp","${SL}temp",
> 	   "${vol}${SL}Temporary Items",
>             "${SL}WWW_ROOT", "${SL}SYS\$SCRATCH",
> 	   "C:${SL}system${SL}temp");
>      unshift(@TEMP,$ENV{'TMPDIR'}) if exists $ENV{'TMPDIR'};

Wow, that's pretty cool.  Hey, if it works...

> of course if we can use existing library functions that would be more 
> portable I think.
> POSIX systems has tmpnam().
> BSD 4.3 has tempnam().
> That's all I know.

I think these functions (at least tmpnam) are more about generating
unique file -names- that won't clash with the other names generated by
that function.  Unfortunately they won't give you a full path in a
writable location or anything like that.

View raw message