apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr/include apr_file_io.h
Date Wed, 23 May 2001 14:49:30 GMT
rbb         01/05/23 07:49:30

  Modified:    file_io/unix seek.c
               include  apr_file_io.h
  Log:
  Add a function to truncate a file without having to close and re-open
  the file.
  
  Revision  Changes    Path
  1.21      +9 -0      apr/file_io/unix/seek.c
  
  Index: seek.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/seek.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -d -b -w -u -r1.20 -r1.21
  --- seek.c	2001/02/16 04:15:37	1.20
  +++ seek.c	2001/05/23 14:49:17	1.21
  @@ -53,6 +53,7 @@
    */
   
   #include "fileio.h"
  +#include <unistd.h>
   
   static apr_status_t setptr(apr_file_t *thefile, unsigned long pos )
   {
  @@ -124,4 +125,12 @@
               return APR_SUCCESS;
           }
       }
  +}
  +
  +apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset)
  +{
  +    if (ftruncate(fp->filedes, offset) == -1) {
  +        return errno;
  +    }
  +    return setptr(fp, offset);
   }
  
  
  
  1.101     +8 -0      apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_file_io.h,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -d -b -w -u -r1.100 -r1.101
  --- apr_file_io.h	2001/05/07 18:04:06	1.100
  +++ apr_file_io.h	2001/05/23 14:49:25	1.101
  @@ -532,6 +532,14 @@
                                             apr_int32_t wanted,
                                             apr_file_t *thefile);
   
  +
  +/**
  + * Truncate the file's length to the specified offset
  + * @param fp The file to truncate
  + * @param offset The offset to truncate to.
  + */
  +APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset);
  +
   /**
    * Get the pool used by the file.
    * @return apr_pool_t the pool
  
  
  

Mime
View raw message