apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/file_io/win32 open.c
Date Thu, 25 Jan 2001 20:29:42 GMT
wrowe       01/01/25 12:29:42

  Modified:    file_io/win32 open.c
  Log:
    Replaced use of unsupported function MoveFileEx() with MoveFile() for
    pre-Windows NT (Win95/98) OS levels.  This may require a look-see in
    the future, but adds functionality where none was present.
  
  Submitted by:	Mike Pilato <cmpilato@collab.net>
  
  Revision  Changes    Path
  1.66      +24 -4     apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/open.c,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- open.c	2001/01/25 15:33:58	1.65
  +++ open.c	2001/01/25 20:29:39	1.66
  @@ -340,10 +340,10 @@
                                             const char *topath,
                                             apr_pool_t *cont)
   {
  -#if APR_HAS_UNICODE_FS
       apr_oslevel_e os_level;
       if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT) 
       {
  +#if APR_HAS_UNICODE_FS
           apr_wchar_t wfrompath[APR_PATH_MAX], wtopath[APR_PATH_MAX];
           apr_status_t rv;
           if (rv = utf8_to_unicode_path(wfrompath, sizeof(wfrompath) 
  @@ -357,12 +357,32 @@
           if (MoveFileExW(wfrompath, wtopath, MOVEFILE_REPLACE_EXISTING |
                                               MOVEFILE_COPY_ALLOWED))
               return APR_SUCCESS;
  -    }
  -    else
  -#endif
  +#else
           if (MoveFileEx(frompath, topath, MOVEFILE_REPLACE_EXISTING |
                                            MOVEFILE_COPY_ALLOWED))
               return APR_SUCCESS;
  +#endif
  +    }
  +    else
  +    {
  +        /* Windows 95 and 98 do not support MoveFileEx, so we'll use
  +         * the old MoveFile function.  However, MoveFile requires that
  +         * the new file not already exist...so we have to delete that
  +         * file if it does.  Perhaps we should back up the to-be-deleted
  +         * file in case something happens?
  +         */
  +        HANDLE handle = INVALID_HANDLE_VALUE;
  +
  +        if ((handle = CreateFile(topath, GENERIC_WRITE, 0, 0,  
  +            OPEN_EXISTING, 0, 0 )) != INVALID_HANDLE_VALUE )
  +        {
  +            CloseHandle(handle);
  +            if (!DeleteFile(topath))
  +                return apr_get_os_error();
  +        }
  +        if (MoveFile(frompath, topath))
  +            return APR_SUCCESS;
  +    }        
       return apr_get_os_error();
   }
   
  
  
  

Mime
View raw message