From cvs-return-3722-apmail-apr-cvs-archive=apr.apache.org@apr.apache.org Wed Jul 10 09:44:57 2002 Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 56723 invoked by uid 500); 10 Jul 2002 09:44:57 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 56712 invoked from network); 10 Jul 2002 09:44:57 -0000 Date: 10 Jul 2002 09:44:55 -0000 Message-ID: <20020710094455.27402.qmail@icarus.apache.org> From: bjh@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/file_io/os2 filedup.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bjh 2002/07/10 02:44:55 Modified: file_io/os2 filedup.c Log: OS/2: Add implementation of apr_file_setaside(). Revision Changes Path 1.28 +43 -0 apr/file_io/os2/filedup.c Index: filedup.c =================================================================== RCS file: /home/cvs/apr/file_io/os2/filedup.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- filedup.c 20 Mar 2002 08:54:42 -0000 1.27 +++ filedup.c 10 Jul 2002 09:44:55 -0000 1.28 @@ -117,3 +117,46 @@ { return file_dup(&new_file, old_file, p); } + + + +APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, + apr_file_t *old_file, + apr_pool_t *p) +{ + *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); + memcpy(*new_file, old_file, sizeof(apr_file_t)); + (*new_file)->pool = p; + + if (old_file->buffered) { + (*new_file)->buffer = apr_palloc(p, APR_FILE_BUFSIZE); + + if (old_file->direction == 1) { + memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); + } + else { + memcpy((*new_file)->buffer, old_file->buffer, old_file->dataRead); + } + + if (old_file->mutex) { + apr_thread_mutex_create(&((*new_file)->mutex), + APR_THREAD_MUTEX_DEFAULT, p); + apr_thread_mutex_destroy(old_file->mutex); + } + } + + if (old_file->fname) { + (*new_file)->fname = apr_pstrdup(p, old_file->fname); + } + + if (!(old_file->flags & APR_FILE_NOCLEANUP)) { + apr_pool_cleanup_register(p, (void *)(*new_file), + apr_file_cleanup, + apr_file_cleanup); + } + + old_file->filedes = -1; + apr_pool_cleanup_kill(old_file->pool, (void *)old_file, + apr_file_cleanup); + return APR_SUCCESS; +}