httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/file_io/win32 open.c
Date Fri, 07 Jul 2000 02:16:01 GMT
gstein      00/07/06 19:16:01

  Modified:    src/lib/apr/include apr_file_io.h
               src/lib/apr/file_io/os2 open.c
               src/lib/apr/file_io/unix open.c
               src/lib/apr/file_io/win32 open.c
  Log:
  add ap_rename_file()
  
  Revision  Changes    Path
  1.59      +19 -0     apache-2.0/src/lib/apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- apr_file_io.h	2000/07/03 12:06:26	1.58
  +++ apr_file_io.h	2000/07/07 02:15:59	1.59
  @@ -188,6 +188,25 @@
   
   /*
   
  +=head1 ap_status_t ap_rename_file(const char *from_path, const char *to_path,
  +                                  ap_pool_t *cont) 
  +
  +B<rename the specified file.>
  +
  +    arg 1) The full path to the original file (using / on all systems)
  +    arg 2) The full path to the new file (using / on all systems)
  +    arg 3) The pool to use.
  +
  +B<NOTE>: If a file exists at the new location, then it will be overwritten.
  +    Moving files or directories across devices may not be possible.
  +
  +=cut
  + */
  +ap_status_t ap_rename_file(const char *from_path, const char *to_path,
  +                           ap_pool_t *pool);
  +
  +/*
  +
   =head1 ap_status_t ap_eof(ap_file_t *fptr) 
   
   B<Are we at the end of the file>
  
  
  
  1.28      +13 -0     apache-2.0/src/lib/apr/file_io/os2/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/os2/open.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- open.c	2000/06/15 17:39:13	1.27
  +++ open.c	2000/07/07 02:16:00	1.28
  @@ -188,6 +188,19 @@
   
   
   
  +ap_status_t ap_rename_file(const char *from_path, const char *to_path,
  +                           ap_pool_t *p)
  +{
  +    /* ### use an OS/2 specific function and error handling here... */
  +    if (rename(from_path, to_path) != 0) {
  +        /* ### wrong error code, but we don't have APR_ERROR */
  +        return APR_EINVAL;
  +    }
  +    return APR_SUCCESS;
  +}
  +
  +
  +
   ap_status_t ap_get_os_file(ap_os_file_t *thefile, ap_file_t *file)
   {
       if (file == NULL) {
  
  
  
  1.61      +9 -0      apache-2.0/src/lib/apr/file_io/unix/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/open.c,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- open.c	2000/07/03 12:06:29	1.60
  +++ open.c	2000/07/07 02:16:01	1.61
  @@ -195,6 +195,15 @@
       }
   }
   
  +ap_status_t ap_rename_file(const char *from_path, const char *to_path,
  +                           ap_pool_t *p)
  +{
  +    if (rename(from_path, to_path) != 0) {
  +        return errno;
  +    }
  +    return APR_SUCCESS;
  +}
  +
   ap_status_t ap_get_os_file(ap_os_file_t *thefile, ap_file_t *file)
   {
       if (file == NULL) {
  
  
  
  1.44      +26 -0     apache-2.0/src/lib/apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/open.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- open.c	2000/07/03 03:21:10	1.43
  +++ open.c	2000/07/07 02:16:01	1.44
  @@ -209,6 +209,32 @@
       }
   }
   
  +ap_status_t ap_rename_file(const char *from_path, const char *to_path,
  +                           ap_pool_t *p)
  +{
  +    const char *from_canon = canonical_filename(p, from_path);
  +    const char *to_canon = canonical_filename(p, to_path);
  +    DWORD err;
  +
  +    /* ### would be nice to use MoveFileEx() here, but it isn't available
  +       ### on Win95/98. MoveFileEx could theoretically help prevent the
  +       ### case where we delete the target but don't move the file(!).
  +       ### it can also copy across devices...
  +    */
  +
  +    if (MoveFile(from_canon, to_canon)) {
  +        return APR_SUCCESS;
  +    }
  +    err = GetLastError();
  +    if (err == ERROR_FILE_EXISTS || err == ERROR_ALREADY_EXISTS) {
  +        (void) DeleteFile(to_canon);
  +        if (MoveFile(from_canon, to_canon))
  +            return APR_SUCCESS;
  +        err = GetLastError();
  +    }
  +    return err;
  +}
  +
   ap_status_t ap_get_os_file(ap_os_file_t *thefile, ap_file_t *file)
   {
       if (file == NULL) {
  
  
  

Mime
View raw message