summaryrefslogtreecommitdiff
path: root/shared/dst_hack.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:08:42 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:08:42 +0200
commitc32707148292d104c66276b43796d6057c8c7a5d (patch)
treebb83513f4aff24153e21a4ec92e34e4c27651b1f /shared/dst_hack.h
parent3.9 (diff)
downloadFreeFileSync-c32707148292d104c66276b43796d6057c8c7a5d.tar.gz
FreeFileSync-c32707148292d104c66276b43796d6057c8c7a5d.tar.bz2
FreeFileSync-c32707148292d104c66276b43796d6057c8c7a5d.zip
3.10
Diffstat (limited to 'shared/dst_hack.h')
-rw-r--r--shared/dst_hack.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/shared/dst_hack.h b/shared/dst_hack.h
new file mode 100644
index 00000000..550098a2
--- /dev/null
+++ b/shared/dst_hack.h
@@ -0,0 +1,38 @@
+#ifndef DST_HACK_H_INCLUDED
+#define DST_HACK_H_INCLUDED
+
+#include <wx/msw/wrapwin.h> //includes "windows.h"
+#include "zstring.h"
+#include <stdexcept>
+
+
+namespace dst
+{
+/*
+Solve DST +-1h and time zone shift issues on FAT drives
+-------------------------------------------------------
+- (local) last write time is not touched!
+- all additional metadata is encoded in local create time:
+ I. indicator that offset in II) is present
+ II. local<->UTC time offset
+ III. indicator that offset in II) corresponds to current local write time (a hash of local last write time)
+*/
+
+bool isFatDrive(const Zstring& fileName); //throw ()
+
+//all subsequent functions may throw the std::runtime_error exception!
+
+struct RawTime //time as retrieved by ::FindFirstFile() and ::GetFileAttributesEx()
+{
+ RawTime(const FILETIME& create, const FILETIME& lastWrite) : createTimeRaw(create), writeTimeRaw(lastWrite) {}
+ FILETIME createTimeRaw;
+ FILETIME writeTimeRaw;
+};
+//save UTC time resistant against DST/time zone shifts
+bool fatHasUtcEncoded(const RawTime& rawTime); //as retrieved by ::FindFirstFile() and ::GetFileAttributesEx(); throw (std::runtime_error)
+
+RawTime fatEncodeUtcTime(const FILETIME& writeTimeRealUtc); //throw (std::runtime_error)
+FILETIME fatDecodeUtcTime(const RawTime& rawTime); //return last write time in real UTC; throw (std::runtime_error)
+}
+
+#endif // DST_HACK_H_INCLUDED
bgstack15