]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filename.cpp
corrected MacSetSelection which was incorrectly deselecting also the previously selec...
[wxWidgets.git] / src / common / filename.cpp
index d3f34e5aa2e9e7a573a3cf850093753fd68e04f8..38f20fee49fd8de3840fbf243ddf0d65607349b3 100644 (file)
@@ -53,6 +53,8 @@
 #ifdef __UNIX_LIKE__
     #include <sys/types.h>
     #include <utime.h>
+    #include <sys/stat.h>
+    #include <unistd.h>
 #endif
 
 // ----------------------------------------------------------------------------
@@ -118,14 +120,32 @@ private:
 // convert between wxDateTime and FILETIME which is a 64-bit value representing
 // the number of 100-nanosecond intervals since January 1, 1601.
 
-static void ConvertWxToFileTime(FILETIME *ft, const wxDateTime& dt)
+// the number of milliseconds between the Unix Epoch (January 1, 1970) and the
+// FILETIME reference point (January 1, 1601)
+static const wxLongLong FILETIME_EPOCH_OFFSET = wxLongLong(0xa97, 0x30b66800);
+
+static void ConvertFileTimeToWx(wxDateTime *dt, const FILETIME &ft)
 {
-    // TODO
+    wxLongLong ll(ft.dwHighDateTime, ft.dwLowDateTime);
+
+    // convert 100ns to ms
+    ll /= 10000;
+
+    // move it to our Epoch
+    ll -= FILETIME_EPOCH_OFFSET;
+
+    *dt = wxDateTime(ll);
 }
 
-static void ConvertFileTimeToWx(wxDateTime *dt, const FILETIME &ft)
+static void ConvertWxToFileTime(FILETIME *ft, const wxDateTime& dt)
 {
-    // TODO
+    // do the reverse of ConvertFileTimeToWx()
+    wxLongLong ll = dt.GetValue();
+    ll *= 10000;
+    ll += FILETIME_EPOCH_OFFSET;
+
+    ft->dwHighDateTime = ll.GetHi();
+    ft->dwLowDateTime = ll.GetLo();
 }
 
 #endif // __WIN32__
@@ -791,7 +811,7 @@ wxPathFormat wxFileName::GetFormat( wxPathFormat format )
     {
 #if defined(__WXMSW__) || defined(__WXPM__)
         format = wxPATH_DOS;
-#elif defined(__WXMAC__)
+#elif defined(__WXMAC__) && !defined(__DARWIN__)
         format = wxPATH_MAC; 
 #else
         format = wxPATH_UNIX;