1 // Windows/PropVariantConv.h
2
3 #ifndef ZIP7_INC_PROP_VARIANT_CONV_H
4 #define ZIP7_INC_PROP_VARIANT_CONV_H
5
6 #include "../Common/MyTypes.h"
7
8 // provide at least 32 bytes for buffer including zero-end
9
10 extern bool g_Timestamp_Show_UTC;
11
12 #define kTimestampPrintLevel_DAY -3
13 // #define kTimestampPrintLevel_HOUR -2
14 #define kTimestampPrintLevel_MIN -1
15 #define kTimestampPrintLevel_SEC 0
16 #define kTimestampPrintLevel_NTFS 7
17 #define kTimestampPrintLevel_NS 9
18
19
20 #define kTimestampPrintFlags_Force_UTC (1 << 0)
21 #define kTimestampPrintFlags_Force_LOCAL (1 << 1)
22 #define kTimestampPrintFlags_DisableZ (1 << 4)
23
24 bool ConvertUtcFileTimeToString(const FILETIME &ft, char *s, int level = kTimestampPrintLevel_SEC) throw();
25 bool ConvertUtcFileTimeToString(const FILETIME &ft, wchar_t *s, int level = kTimestampPrintLevel_SEC) throw();
26 bool ConvertUtcFileTimeToString2(const FILETIME &ft, unsigned ns100, char *s, int level = kTimestampPrintLevel_SEC, unsigned flags = 0) throw();
27 bool ConvertUtcFileTimeToString2(const FILETIME &ft, unsigned ns100, wchar_t *s, int level = kTimestampPrintLevel_SEC) throw();
28
29 // provide at least 32 bytes for buffer including zero-end
30 // don't send VT_BSTR to these functions
31 void ConvertPropVariantToShortString(const PROPVARIANT &prop, char *dest) throw();
32 void ConvertPropVariantToShortString(const PROPVARIANT &prop, wchar_t *dest) throw();
33
ConvertPropVariantToUInt64(const PROPVARIANT & prop,UInt64 & value)34 inline bool ConvertPropVariantToUInt64(const PROPVARIANT &prop, UInt64 &value)
35 {
36 switch (prop.vt)
37 {
38 case VT_UI8: value = (UInt64)prop.uhVal.QuadPart; return true;
39 case VT_UI4: value = prop.ulVal; return true;
40 case VT_UI2: value = prop.uiVal; return true;
41 case VT_UI1: value = prop.bVal; return true;
42 case VT_EMPTY: return false;
43 default: throw 151199;
44 }
45 }
46
47 #endif
48