apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mladen Turk" <mt...@mappingsoft.com>
Subject [PATCH] apr_file_mktemp
Date Sat, 06 Oct 2001 12:02:19 GMT
Hi all,

apr_file_mktemp behaves differenty on WIN platform then on UNIX.
When you call the apr_file_mktemp on UNIX you'll get the opened apr_file_t.

Here is the patch that solves that behavior. When you call the
apr_file_mktem with valid
apr_file_t param you'll get the file opened file, and if you use the NULL as
apr_file_t param,
only the fname will be filled with temporyry file name.

MT.


Index: mktemp.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/unix/mktemp.c,v
retrieving revision 1.11
diff -u -r1.11 mktemp.c
--- mktemp.c	2001/10/01 19:12:49	1.11
+++ mktemp.c	2001/10/06 11:44:09
@@ -68,7 +68,7 @@
 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 static apr_uint32_t randseed=0;

-static int gettemp(char *path, apr_file_t *doopen, int domkdir, int slen,
+static int gettemp(char *path, apr_file_t **doopen, int domkdir, int slen,
                    apr_pool_t *p)
 {
 	register char *start, *trv, *suffp;
@@ -128,7 +128,7 @@
 	for (;;) {
 		errno = 0;
 		if (doopen) {
-			if ((rv = apr_file_open(&doopen, path,
APR_CREATE|APR_EXCL|APR_READ|APR_WRITE,
+			if ((rv = apr_file_open(doopen, path,
APR_CREATE|APR_EXCL|APR_READ|APR_WRITE|APR_DELONCLOSE,
                                     APR_UREAD | APR_UWRITE, p)) ==
APR_SUCCESS)
 				return(1);
 			if (errno != EEXIST)
@@ -176,8 +176,10 @@
     int fd;
 #endif

+
 #ifndef HAVE_MKSTEMP
-    rv = gettemp(template, (*fp), 0, 0, p);
+
+    rv = gettemp(template, fp, 0, 0, p);
     if (rv == 0) {
         return errno;
     }
@@ -196,13 +198,7 @@
     (*fp)->filedes = fd;

 #endif
-#ifdef WIN32
-    apr_pool_cleanup_register((*fp)->cntxt, (void *)(*fp),
-                              file_cleanup, file_cleanup);
-#elif defined(OS2)
-    apr_pool_cleanup_register((*fp)->cntxt, (void *)(*fp),
-                              apr_file_cleanup, apr_file_cleanup);
-#else
+#if !defined(WIN32) && !defined(OS2)
     apr_pool_cleanup_register((*fp)->cntxt, (void *)(*fp),
                               apr_unix_file_cleanup,
apr_unix_file_cleanup);
 #endif

Mladen Turk
MCSE/GIS Specialist
MappingSoft
mailto: [ mturk@mappingsoft.com ]
http://apache.mappingsoft.com



Mime
View raw message