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;
+}