diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-06-20 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 13:35:20 +0500 |
| commit | a3e1d227377188734b82f023f96f8e25dc40f3e6 (patch) | |
| tree | 23cad8d47eb23d26ea727b4f7f4a65124f724065 /CPP/Windows/PropVariantConv.cpp | |
| parent | f19f813537c7aea1c20749c914e756b54a9c3cf5 (diff) | |
| download | 7zip-a3e1d227377188734b82f023f96f8e25dc40f3e6.tar.gz 7zip-a3e1d227377188734b82f023f96f8e25dc40f3e6.tar.bz2 7zip-a3e1d227377188734b82f023f96f8e25dc40f3e6.zip | |
22.0022.00
Diffstat (limited to 'CPP/Windows/PropVariantConv.cpp')
| -rw-r--r-- | CPP/Windows/PropVariantConv.cpp | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/CPP/Windows/PropVariantConv.cpp b/CPP/Windows/PropVariantConv.cpp index b58d37e..3c9bbd1 100644 --- a/CPP/Windows/PropVariantConv.cpp +++ b/CPP/Windows/PropVariantConv.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | #define UINT_TO_STR_2(c, val) { s[0] = (c); s[1] = (char)('0' + (val) / 10); s[2] = (char)('0' + (val) % 10); s += 3; } | 10 | #define UINT_TO_STR_2(c, val) { s[0] = (c); s[1] = (char)('0' + (val) / 10); s[2] = (char)('0' + (val) % 10); s += 3; } |
| 11 | 11 | ||
| 12 | bool ConvertUtcFileTimeToString(const FILETIME &utc, char *s, int level) throw() | 12 | bool ConvertUtcFileTimeToString2(const FILETIME &utc, unsigned ns100, char *s, int level) throw() |
| 13 | { | 13 | { |
| 14 | *s = 0; | 14 | *s = 0; |
| 15 | FILETIME ft; | 15 | FILETIME ft; |
| @@ -18,7 +18,10 @@ bool ConvertUtcFileTimeToString(const FILETIME &utc, char *s, int level) throw() | |||
| 18 | 18 | ||
| 19 | SYSTEMTIME st; | 19 | SYSTEMTIME st; |
| 20 | if (!BOOLToBool(FileTimeToSystemTime(&ft, &st))) | 20 | if (!BOOLToBool(FileTimeToSystemTime(&ft, &st))) |
| 21 | { | ||
| 22 | // win10 : that function doesn't work, if bit 63 of 64-bit FILETIME is set. | ||
| 21 | return false; | 23 | return false; |
| 24 | } | ||
| 22 | 25 | ||
| 23 | { | 26 | { |
| 24 | unsigned val = st.wYear; | 27 | unsigned val = st.wYear; |
| @@ -71,6 +74,12 @@ bool ConvertUtcFileTimeToString(const FILETIME &utc, char *s, int level) throw() | |||
| 71 | numDigits = (unsigned)level; | 74 | numDigits = (unsigned)level; |
| 72 | s += numDigits; | 75 | s += numDigits; |
| 73 | } | 76 | } |
| 77 | if (level >= kTimestampPrintLevel_NTFS + 1) | ||
| 78 | { | ||
| 79 | *s++ = (char)('0' + (ns100 / 10)); | ||
| 80 | if (level >= kTimestampPrintLevel_NTFS + 2) | ||
| 81 | *s++ = (char)('0' + (ns100 % 10)); | ||
| 82 | } | ||
| 74 | } | 83 | } |
| 75 | } | 84 | } |
| 76 | } | 85 | } |
| @@ -80,6 +89,25 @@ bool ConvertUtcFileTimeToString(const FILETIME &utc, char *s, int level) throw() | |||
| 80 | } | 89 | } |
| 81 | 90 | ||
| 82 | 91 | ||
| 92 | bool ConvertUtcFileTimeToString(const FILETIME &utc, char *s, int level) throw() | ||
| 93 | { | ||
| 94 | return ConvertUtcFileTimeToString2(utc, 0, s, level); | ||
| 95 | } | ||
| 96 | |||
| 97 | bool ConvertUtcFileTimeToString2(const FILETIME &ft, unsigned ns100, wchar_t *dest, int level) throw() | ||
| 98 | { | ||
| 99 | char s[32]; | ||
| 100 | bool res = ConvertUtcFileTimeToString2(ft, ns100, s, level); | ||
| 101 | for (unsigned i = 0;; i++) | ||
| 102 | { | ||
| 103 | Byte c = (Byte)s[i]; | ||
| 104 | dest[i] = c; | ||
| 105 | if (c == 0) | ||
| 106 | break; | ||
| 107 | } | ||
| 108 | return res; | ||
| 109 | } | ||
| 110 | |||
| 83 | bool ConvertUtcFileTimeToString(const FILETIME &ft, wchar_t *dest, int level) throw() | 111 | bool ConvertUtcFileTimeToString(const FILETIME &ft, wchar_t *dest, int level) throw() |
| 84 | { | 112 | { |
| 85 | char s[32]; | 113 | char s[32]; |
| @@ -106,7 +134,19 @@ void ConvertPropVariantToShortString(const PROPVARIANT &prop, char *dest) throw( | |||
| 106 | case VT_UI2: ConvertUInt32ToString(prop.uiVal, dest); return; | 134 | case VT_UI2: ConvertUInt32ToString(prop.uiVal, dest); return; |
| 107 | case VT_UI4: ConvertUInt32ToString(prop.ulVal, dest); return; | 135 | case VT_UI4: ConvertUInt32ToString(prop.ulVal, dest); return; |
| 108 | case VT_UI8: ConvertUInt64ToString(prop.uhVal.QuadPart, dest); return; | 136 | case VT_UI8: ConvertUInt64ToString(prop.uhVal.QuadPart, dest); return; |
| 109 | case VT_FILETIME: ConvertUtcFileTimeToString(prop.filetime, dest); return; | 137 | case VT_FILETIME: |
| 138 | { | ||
| 139 | // const unsigned prec = prop.wReserved1; | ||
| 140 | int level = 0; | ||
| 141 | /* | ||
| 142 | if (prec == 0) | ||
| 143 | level = 7; | ||
| 144 | else if (prec > 16 && prec <= 16 + 9) | ||
| 145 | level = prec - 16; | ||
| 146 | */ | ||
| 147 | ConvertUtcFileTimeToString(prop.filetime, dest, level); | ||
| 148 | return; | ||
| 149 | } | ||
| 110 | // case VT_I1: return ConvertInt64ToString(prop.cVal, dest); return; | 150 | // case VT_I1: return ConvertInt64ToString(prop.cVal, dest); return; |
| 111 | case VT_I2: ConvertInt64ToString(prop.iVal, dest); return; | 151 | case VT_I2: ConvertInt64ToString(prop.iVal, dest); return; |
| 112 | case VT_I4: ConvertInt64ToString(prop.lVal, dest); return; | 152 | case VT_I4: ConvertInt64ToString(prop.lVal, dest); return; |
| @@ -127,7 +167,19 @@ void ConvertPropVariantToShortString(const PROPVARIANT &prop, wchar_t *dest) thr | |||
| 127 | case VT_UI2: ConvertUInt32ToString(prop.uiVal, dest); return; | 167 | case VT_UI2: ConvertUInt32ToString(prop.uiVal, dest); return; |
| 128 | case VT_UI4: ConvertUInt32ToString(prop.ulVal, dest); return; | 168 | case VT_UI4: ConvertUInt32ToString(prop.ulVal, dest); return; |
| 129 | case VT_UI8: ConvertUInt64ToString(prop.uhVal.QuadPart, dest); return; | 169 | case VT_UI8: ConvertUInt64ToString(prop.uhVal.QuadPart, dest); return; |
| 130 | case VT_FILETIME: ConvertUtcFileTimeToString(prop.filetime, dest); return; | 170 | case VT_FILETIME: |
| 171 | { | ||
| 172 | // const unsigned prec = prop.wReserved1; | ||
| 173 | int level = 0; | ||
| 174 | /* | ||
| 175 | if (prec == 0) | ||
| 176 | level = 7; | ||
| 177 | else if (prec > 16 && prec <= 16 + 9) | ||
| 178 | level = prec - 16; | ||
| 179 | */ | ||
| 180 | ConvertUtcFileTimeToString(prop.filetime, dest, level); | ||
| 181 | return; | ||
| 182 | } | ||
| 131 | // case VT_I1: return ConvertInt64ToString(prop.cVal, dest); return; | 183 | // case VT_I1: return ConvertInt64ToString(prop.cVal, dest); return; |
| 132 | case VT_I2: ConvertInt64ToString(prop.iVal, dest); return; | 184 | case VT_I2: ConvertInt64ToString(prop.iVal, dest); return; |
| 133 | case VT_I4: ConvertInt64ToString(prop.lVal, dest); return; | 185 | case VT_I4: ConvertInt64ToString(prop.lVal, dest); return; |
