]> git.saurik.com Git - wxWidgets.git/commitdiff
implement SetTimes() for directories too under MSW (#10250)
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 16 Jan 2009 18:03:00 +0000 (18:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 16 Jan 2009 18:03:00 +0000 (18:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/filename.cpp

index db956a1b46c6448ce3998b01bb20510cb04c8443..f926ef3c5dacefa658efdf0aa63da8a552310202 100644 (file)
@@ -483,6 +483,7 @@ wxMSW:
   accurately represents what will be printed. This fixes wxHtmlEasyPrinting
   preview inaccuracies on Windows; on other platforms, native preview
   should be used.
   accurately represents what will be printed. This fixes wxHtmlEasyPrinting
   preview inaccuracies on Windows; on other platforms, native preview
   should be used.
+- Implement wxFileName::SetTimes() for directories (Steve Lamerton).
 
 wxX11:
 
 
 wxX11:
 
index 508954f955161f594ca10a78cf995247e7ae988d..4e21ea14495d0a4e83a13ca0cdd03ac9471f5c7e 100644 (file)
@@ -161,7 +161,7 @@ public:
         Write
     };
 
         Write
     };
 
-    wxFileHandle(const wxString& filename, OpenMode mode)
+    wxFileHandle(const wxString& filename, OpenMode mode, int flags = 0)
     {
         m_hFile = ::CreateFile
                     (
     {
         m_hFile = ::CreateFile
                     (
@@ -172,7 +172,7 @@ public:
                      FILE_SHARE_WRITE,              // (allow everything)
                      NULL,                          // no secutity attr
                      OPEN_EXISTING,                 // creation disposition
                      FILE_SHARE_WRITE,              // (allow everything)
                      NULL,                          // no secutity attr
                      OPEN_EXISTING,                 // creation disposition
-                     0,                             // no flags
+                     flags,                         // flags
                      NULL                           // no template file
                     );
 
                      NULL                           // no template file
                     );
 
@@ -2209,32 +2209,44 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
                           const wxDateTime *dtCreate)
 {
 #if defined(__WIN32__)
                           const wxDateTime *dtCreate)
 {
 #if defined(__WIN32__)
+    FILETIME ftAccess, ftCreate, ftWrite;
+
+    if ( dtCreate )
+        ConvertWxToFileTime(&ftCreate, *dtCreate);
+    if ( dtAccess )
+        ConvertWxToFileTime(&ftAccess, *dtAccess);
+    if ( dtMod )
+        ConvertWxToFileTime(&ftWrite, *dtMod);
+
+    wxString path;
+    int flags;
     if ( IsDir() )
     {
     if ( IsDir() )
     {
-        // VZ: please let me know how to do this if you can
-        wxFAIL_MSG( _T("SetTimes() not implemented for the directories") );
+        if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
+        {
+            wxLogError(_("Setting directory access times is not supported "
+                         "under this OS version"));
+            return false;
+        }
+
+        path = GetPath();
+        flags = FILE_FLAG_BACKUP_SEMANTICS;
     }
     else // file
     {
     }
     else // file
     {
-        wxFileHandle fh(GetFullPath(), wxFileHandle::Write);
-        if ( fh.IsOk() )
-        {
-            FILETIME ftAccess, ftCreate, ftWrite;
-
-            if ( dtCreate )
-                ConvertWxToFileTime(&ftCreate, *dtCreate);
-            if ( dtAccess )
-                ConvertWxToFileTime(&ftAccess, *dtAccess);
-            if ( dtMod )
-                ConvertWxToFileTime(&ftWrite, *dtMod);
+        path = GetFullPath();
+        flags = 0;
+    }
 
 
-            if ( ::SetFileTime(fh,
-                               dtCreate ? &ftCreate : NULL,
-                               dtAccess ? &ftAccess : NULL,
-                               dtMod ? &ftWrite : NULL) )
-            {
-                return true;
-            }
+    wxFileHandle fh(path, wxFileHandle::Write, flags);
+    if ( fh.IsOk() )
+    {
+        if ( ::SetFileTime(fh,
+                           dtCreate ? &ftCreate : NULL,
+                           dtAccess ? &ftAccess : NULL,
+                           dtMod ? &ftWrite : NULL) )
+        {
+            return true;
         }
     }
 #elif defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__))
         }
     }
 #elif defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__))