From bd6336c629841c6db3a6ca53a936d629d34db53b Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:15:16 +0200 Subject: 4.1 --- zen/dst_hack.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 zen/dst_hack.h (limited to 'zen/dst_hack.h') diff --git a/zen/dst_hack.h b/zen/dst_hack.h new file mode 100644 index 00000000..07d08dc5 --- /dev/null +++ b/zen/dst_hack.h @@ -0,0 +1,40 @@ +#ifndef DST_HACK_H_INCLUDED +#define DST_HACK_H_INCLUDED + +#include "win.h" //includes "windows.h" +#include "zstring.h" +#include + + +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 () +bool isFatDrive(HANDLE hFile); //throw() -> call ONLY if vistaOrLater() == true! +bool vistaOrLater(); + +//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 -- cgit