Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 48998 invoked by uid 500); 6 Oct 2001 11:54:42 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 48987 invoked from network); 6 Oct 2001 11:54:42 -0000 From: "Mladen Turk" To: "APR Dev List" Subject: [PATCH] apr_file_mktemp Date: Sat, 6 Oct 2001 14:02:19 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ns.promo-grupa.com X-AntiAbuse: Original Domain - apr.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [0 0] X-AntiAbuse: Sender Address Domain - mappingsoft.com X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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