You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2022/01/02 13:21:12 UTC

svn commit: r1896623 - in /apr/apr/trunk: CHANGES file_io/win32/filestat.c

Author: ivan
Date: Sun Jan  2 13:21:12 2022
New Revision: 1896623

URL: http://svn.apache.org/viewvc?rev=1896623&view=rev
Log:
Optimize apr_file_mtime_set() on Windows.

* file_io/win32/filestat.c
  (apr_file_mtime_set): Pass NULL as ATIME and CTIME when calling SetFileTime()
   to prevent changing ATIME and CTIME instead of retrieving these times using
   GetFileTime().

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/file_io/win32/filestat.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1896623&r1=1896622&r2=1896623&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Sun Jan  2 13:21:12 2022
@@ -258,6 +258,8 @@ Changes for APR 2.0.0
   *) apr_proc_create(): Properly escape arguments containing whitespace
      characters on Windows [Ivan Zhakov]
 
+  *) apr_file_mtime_set(): Minor optimization on Windows. [Ivan Zhakov]
+
 Changes for APR and APR-util 1.7.x and later:
 
   *) http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/CHANGES?view=markup

Modified: apr/apr/trunk/file_io/win32/filestat.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/filestat.c?rev=1896623&r1=1896622&r2=1896623&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/filestat.c (original)
+++ apr/apr/trunk/file_io/win32/filestat.c Sun Jan  2 13:21:12 2022
@@ -752,20 +752,11 @@ APR_DECLARE(apr_status_t) apr_file_mtime
                        APR_FPROT_OS_DEFAULT, pool);
     if (!rv)
     {
-        FILETIME file_ctime;
-        FILETIME file_atime;
         FILETIME file_mtime;
 
-        if (!GetFileTime(thefile->filehand,
-                         &file_ctime, &file_atime, &file_mtime))
+        AprTimeToFileTime(&file_mtime, mtime);
+        if (!SetFileTime(thefile->filehand, NULL, NULL, &file_mtime))
             rv = apr_get_os_error();
-        else
-        {
-            AprTimeToFileTime(&file_mtime, mtime);
-            if (!SetFileTime(thefile->filehand,
-                             &file_ctime, &file_atime, &file_mtime))
-                rv = apr_get_os_error();
-        }
 
         apr_file_close(thefile);
     }