rbb 99/12/30 11:50:31
Modified: src/lib/apr/file_io/unix open.c src/lib/apr/include apr_file_io.h Log: Add a flag to ap_open to allow close on delete status. This should be the preferred way to delete a file after closing it, rather than unlinking the file immediately after opening it. This is more portable, and was can code this option to work on all platforms, the unlink option is not always possible. Revision Changes Path 1.28 +5 -1 apache-2.0/src/lib/apr/file_io/unix/open.c Index: open.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/open.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- open.c 1999/12/13 13:57:06 1.27 +++ open.c 1999/12/30 19:50:20 1.28 @@ -93,6 +93,7 @@ * APR_BINARY not a text file (This flag is ignored on UNIX because it has no meaning) * APR_BUFFERED buffer the data. Default is non-buffered * APR_EXCL return error if APR_CREATE and file exists + * APR_DELONCLOSE delete the file after closing. * arg 4) Access permissions for file. * arg 5) The opened file descriptor. * NOTE: If mode is APR_OS_DEFAULT, the system open command will be @@ -167,9 +168,12 @@ if ((*new)->filedes < 0 && (*new)->filehand == NULL) { (*new)->filedes = -1; (*new)->eof_hit = 1; - return errno; + return errno; } + if (flag & APR_DELONCLOSE) { + unlink(fname); + } (*new)->stated = 0; /* we haven't called stat for this file yet. */ (*new)->timeout = -1; (*new)->eof_hit = 0; 1.23 +9 -8 apache-2.0/src/lib/apr/include/apr_file_io.h Index: apr_file_io.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- apr_file_io.h 1999/12/11 20:24:14 1.22 +++ apr_file_io.h 1999/12/30 19:50:28 1.23 @@ -70,15 +70,16 @@ APR_SOCK} ap_filetype_e; /* Flags for ap_open */ -#define APR_READ 1 /* Open the file for reading */ -#define APR_WRITE 2 /* Open the file for writing */ -#define APR_CREATE 4 /* Create the file if not there */ -#define APR_APPEND 8 /* Append to the end of the file */ -#define APR_TRUNCATE 16 /* Open the file and truncate to 0 length */ -#define APR_BINARY 32 /* Open the file in binary mode */ -#define APR_BUFFERED 64 /* Buffer the data when reading or writing */ -#define APR_EXCL 128 /* Open should fail if APR_CREATE and file +#define APR_READ 1 /* Open the file for reading */ +#define APR_WRITE 2 /* Open the file for writing */ +#define APR_CREATE 4 /* Create the file if not there */ +#define APR_APPEND 8 /* Append to the end of the file */ +#define APR_TRUNCATE 16 /* Open the file and truncate to 0 length */ +#define APR_BINARY 32 /* Open the file in binary mode */ +#define APR_BUFFERED 64 /* Buffer the data when reading or writing */ +#define APR_EXCL 128 /* Open should fail if APR_CREATE and file exists. */ +#define APR_DELONCLOSE 256 /* Delete the file after close */ /* flags for ap_seek */ #define APR_SET SEEK_SET