apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wilfredo Sánchez <wsanc...@wsanchez.net>
Subject Re: [time to move on I guess] APR_TMP_DIRECTORY
Date Tue, 17 Dec 2002 07:22:37 GMT
   Thanks, Brane.

   David, I apologize if I contributed to discouraging you from coding.

   At the risk of repeating that mistake, I thought of something today I 
thought I'd share. :-)

   The SVN folks pointed out that we don't have a way of getting a file 
name back for the temp file created by apr_file_mktemp(), because it 
just gives you the file handle.  It was suggested that we need another 
function for that.

   It dawns on me that it might be way cool if apr_file_mktemp() could 
give you back both a filehandle and optionally the file name, so that 
you get the name, but it can still also create the file for you and 
avoid the race condition between getting the name and opening the file. 
  We wouldn't be able to implement it with mkstemp() any more, though.


On Monday, December 16, 2002, at 05:19  PM, Branko Čibej wrote:

> David Reid wrote:
>> Actually my memory is that we don't any form of agreement on how this 
>> should
>> be implemented or even what problem the discussion was trying to 
>> solve -
>> that's why I haven't written anything yet. I was all set to write the 
>> code
>> but the discussion and feeling expressed mean I won't now.
>> It'll be nice if we ever do it as it means that apache might build on 
>> beos
>> again :)
> O.K., let's restate what we want:
> 1) A function that creates and opens a temporary file, accepting a
> template name.
>     We have that, it's called apr_file_mktemp.
> 2) A function that gives us the name of a directory where temporary
> files may be created; this name would be used to create template names
> for apr_file_mktemp.
>     We don't have that, but need it. Applying the keep-it-simple
>     principle, the definitiona would be
>     const char *apr_filepath_temp_dir_get (apr_pool_t *pool);
>     The implementation should use any system-specific APIs and/or
>     conventions to find a directory that a) is customarily used for
>     creating temporary files, and b) is writable by the current 
> process.
>     We /may/ want to qualify if the temp dir should be such that files
>     in it survive a reboot or not.
> 3) [I'm not sure we need this, but I'm adding it for completeness] A
> function that creates a temporary directory, accepting a template name.
>     This would be symmetric to apr_file_mktemp:
>     apr_status_t apr_dir_mktemp (const char **real_name,
>                                  const char *templ,
>                                  apr_int32_t flags,
>                                  apr_pool_t *pool);
>     It would use the same method as apr_file_mktemp to create a unique
>     name, then create the directory and return that name. Unlike
>     apr_file_mktemp, it would not automaticlaly remove the directory, 
> of
>     course. The caller must still use apr_filepath_temp_dir_get to
>     create the template for a name that's within the temporary 
> directory.
> There. The implementation is an exercise for the reader. I volunteer to
> write the Windows-specific apr_filepath_temp_dir_get when the time 
> comes.
> -- 
> Brane Čibej   <brane@xbc.nu>   http://www.xbc.nu/brane/

View raw message