diff options
Diffstat (limited to '')
50 files changed, 2922 insertions, 2257 deletions
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp index d88c851..2bdbc41 100644 --- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp +++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | 17 | ||
18 | #ifdef _7ZIP_LARGE_PAGES | 18 | #ifdef Z7_LARGE_PAGES |
19 | #include "../../../../C/Alloc.h" | 19 | #include "../../../../C/Alloc.h" |
20 | #endif | 20 | #endif |
21 | 21 | ||
@@ -42,7 +42,7 @@ | |||
42 | extern bool g_CaseSensitive; | 42 | extern bool g_CaseSensitive; |
43 | extern bool g_PathTrailReplaceMode; | 43 | extern bool g_PathTrailReplaceMode; |
44 | 44 | ||
45 | #ifdef _7ZIP_LARGE_PAGES | 45 | #ifdef Z7_LARGE_PAGES |
46 | extern | 46 | extern |
47 | bool g_LargePagesMode; | 47 | bool g_LargePagesMode; |
48 | bool g_LargePagesMode = false; | 48 | bool g_LargePagesMode = false; |
@@ -174,7 +174,7 @@ enum Enum | |||
174 | kDeleteAfterCompressing, | 174 | kDeleteAfterCompressing, |
175 | kSetArcMTime | 175 | kSetArcMTime |
176 | 176 | ||
177 | #ifndef _NO_CRYPTO | 177 | #ifndef Z7_NO_CRYPTO |
178 | , kPassword | 178 | , kPassword |
179 | #endif | 179 | #endif |
180 | }; | 180 | }; |
@@ -322,7 +322,7 @@ static const CSwitchForm kSwitchForms[] = | |||
322 | { "sdel", SWFRM_SIMPLE }, | 322 | { "sdel", SWFRM_SIMPLE }, |
323 | { "stl", SWFRM_SIMPLE } | 323 | { "stl", SWFRM_SIMPLE } |
324 | 324 | ||
325 | #ifndef _NO_CRYPTO | 325 | #ifndef Z7_NO_CRYPTO |
326 | , { "p", SWFRM_STRING } | 326 | , { "p", SWFRM_STRING } |
327 | #endif | 327 | #endif |
328 | }; | 328 | }; |
@@ -340,7 +340,7 @@ static const char * const kEmptyFilePath = "Empty file path"; | |||
340 | 340 | ||
341 | bool CArcCommand::IsFromExtractGroup() const | 341 | bool CArcCommand::IsFromExtractGroup() const |
342 | { | 342 | { |
343 | switch (CommandType) | 343 | switch ((int)CommandType) |
344 | { | 344 | { |
345 | case NCommandType::kTest: | 345 | case NCommandType::kTest: |
346 | case NCommandType::kExtract: | 346 | case NCommandType::kExtract: |
@@ -353,7 +353,7 @@ bool CArcCommand::IsFromExtractGroup() const | |||
353 | 353 | ||
354 | NExtract::NPathMode::EEnum CArcCommand::GetPathMode() const | 354 | NExtract::NPathMode::EEnum CArcCommand::GetPathMode() const |
355 | { | 355 | { |
356 | switch (CommandType) | 356 | switch ((int)CommandType) |
357 | { | 357 | { |
358 | case NCommandType::kTest: | 358 | case NCommandType::kTest: |
359 | case NCommandType::kExtractFull: | 359 | case NCommandType::kExtractFull: |
@@ -365,7 +365,7 @@ NExtract::NPathMode::EEnum CArcCommand::GetPathMode() const | |||
365 | 365 | ||
366 | bool CArcCommand::IsFromUpdateGroup() const | 366 | bool CArcCommand::IsFromUpdateGroup() const |
367 | { | 367 | { |
368 | switch (CommandType) | 368 | switch ((int)CommandType) |
369 | { | 369 | { |
370 | case NCommandType::kAdd: | 370 | case NCommandType::kAdd: |
371 | case NCommandType::kUpdate: | 371 | case NCommandType::kUpdate: |
@@ -438,7 +438,7 @@ static void AddNameToCensor(NWildcard::CCensor &censor, | |||
438 | { | 438 | { |
439 | bool recursed = false; | 439 | bool recursed = false; |
440 | 440 | ||
441 | switch (nop.RecursedType) | 441 | switch ((int)nop.RecursedType) |
442 | { | 442 | { |
443 | case NRecursedType::kWildcardOnlyRecursed: | 443 | case NRecursedType::kWildcardOnlyRecursed: |
444 | recursed = DoesNameContainWildcard(name); | 444 | recursed = DoesNameContainWildcard(name); |
@@ -905,7 +905,7 @@ static void SetAddCommandOptions( | |||
905 | CUpdateOptions &options) | 905 | CUpdateOptions &options) |
906 | { | 906 | { |
907 | NUpdateArchive::CActionSet defaultActionSet; | 907 | NUpdateArchive::CActionSet defaultActionSet; |
908 | switch (commandType) | 908 | switch ((int)commandType) |
909 | { | 909 | { |
910 | case NCommandType::kAdd: | 910 | case NCommandType::kAdd: |
911 | defaultActionSet = NUpdateArchive::k_ActionSet_Add; | 911 | defaultActionSet = NUpdateArchive::k_ActionSet_Add; |
@@ -944,8 +944,10 @@ static void SetAddCommandOptions( | |||
944 | FOR_VECTOR (i, sv) | 944 | FOR_VECTOR (i, sv) |
945 | { | 945 | { |
946 | UInt64 size; | 946 | UInt64 size; |
947 | if (!ParseComplexSize(sv[i], size) || size == 0) | 947 | if (!ParseComplexSize(sv[i], size)) |
948 | throw CArcCmdLineException("Incorrect volume size:", sv[i]); | 948 | throw CArcCmdLineException("Incorrect volume size:", sv[i]); |
949 | if (i == sv.Size() - 1 && size == 0) | ||
950 | throw CArcCmdLineException("zero size last volume is not allowed"); | ||
949 | options.VolumesSizes.Add(size); | 951 | options.VolumesSizes.Add(size); |
950 | } | 952 | } |
951 | } | 953 | } |
@@ -992,7 +994,7 @@ void CArcCmdLineParser::Parse1(const UStringVector &commandStrings, | |||
992 | CArcCmdLineOptions &options) | 994 | CArcCmdLineOptions &options) |
993 | { | 995 | { |
994 | Parse1Log.Empty(); | 996 | Parse1Log.Empty(); |
995 | if (!parser.ParseStrings(kSwitchForms, ARRAY_SIZE(kSwitchForms), commandStrings)) | 997 | if (!parser.ParseStrings(kSwitchForms, Z7_ARRAY_SIZE(kSwitchForms), commandStrings)) |
996 | throw CArcCmdLineException(parser.ErrorMessage, parser.ErrorLine); | 998 | throw CArcCmdLineException(parser.ErrorMessage, parser.ErrorLine); |
997 | 999 | ||
998 | options.IsInTerminal = MY_IS_TERMINAL(stdin); | 1000 | options.IsInTerminal = MY_IS_TERMINAL(stdin); |
@@ -1054,7 +1056,7 @@ void CArcCmdLineParser::Parse1(const UStringVector &commandStrings, | |||
1054 | 1056 | ||
1055 | if (parser[NKey::kLargePages].ThereIs) | 1057 | if (parser[NKey::kLargePages].ThereIs) |
1056 | { | 1058 | { |
1057 | unsigned slp = 0; | 1059 | UInt32 slp = 0; |
1058 | const UString &s = parser[NKey::kLargePages].PostStrings[0]; | 1060 | const UString &s = parser[NKey::kLargePages].PostStrings[0]; |
1059 | if (s.IsEmpty()) | 1061 | if (s.IsEmpty()) |
1060 | slp = 1; | 1062 | slp = 1; |
@@ -1064,7 +1066,7 @@ void CArcCmdLineParser::Parse1(const UStringVector &commandStrings, | |||
1064 | throw CArcCmdLineException("Unsupported switch postfix for -slp", s); | 1066 | throw CArcCmdLineException("Unsupported switch postfix for -slp", s); |
1065 | } | 1067 | } |
1066 | 1068 | ||
1067 | #ifdef _7ZIP_LARGE_PAGES | 1069 | #ifdef Z7_LARGE_PAGES |
1068 | if (slp > | 1070 | if (slp > |
1069 | #if defined(_WIN32) && !defined(UNDER_CE) | 1071 | #if defined(_WIN32) && !defined(UNDER_CE) |
1070 | (unsigned)NSecurity::Get_LargePages_RiskLevel() | 1072 | (unsigned)NSecurity::Get_LargePages_RiskLevel() |
@@ -1181,8 +1183,8 @@ static const CCodePagePair g_CodePagePairs[] = | |||
1181 | { "utf-8", CP_UTF8 }, | 1183 | { "utf-8", CP_UTF8 }, |
1182 | { "win", CP_ACP }, | 1184 | { "win", CP_ACP }, |
1183 | { "dos", CP_OEMCP }, | 1185 | { "dos", CP_OEMCP }, |
1184 | { "utf-16le", MY__CP_UTF16 }, | 1186 | { "utf-16le", Z7_WIN_CP_UTF16 }, |
1185 | { "utf-16be", MY__CP_UTF16BE } | 1187 | { "utf-16be", Z7_WIN_CP_UTF16BE } |
1186 | }; | 1188 | }; |
1187 | 1189 | ||
1188 | static Int32 FindCharset(const NCommandLineParser::CParser &parser, unsigned keyIndex, | 1190 | static Int32 FindCharset(const NCommandLineParser::CParser &parser, unsigned keyIndex, |
@@ -1197,7 +1199,7 @@ static Int32 FindCharset(const NCommandLineParser::CParser &parser, unsigned key | |||
1197 | if (v < ((UInt32)1 << 16)) | 1199 | if (v < ((UInt32)1 << 16)) |
1198 | return (Int32)v; | 1200 | return (Int32)v; |
1199 | name.MakeLower_Ascii(); | 1201 | name.MakeLower_Ascii(); |
1200 | unsigned num = byteOnlyCodePages ? kNumByteOnlyCodePages : ARRAY_SIZE(g_CodePagePairs); | 1202 | const unsigned num = byteOnlyCodePages ? kNumByteOnlyCodePages : Z7_ARRAY_SIZE(g_CodePagePairs); |
1201 | for (unsigned i = 0;; i++) | 1203 | for (unsigned i = 0;; i++) |
1202 | { | 1204 | { |
1203 | if (i == num) // to disable warnings from different compilers | 1205 | if (i == num) // to disable warnings from different compilers |
@@ -1355,7 +1357,7 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options) | |||
1355 | options.YesToAll = parser[NKey::kYes].ThereIs; | 1357 | options.YesToAll = parser[NKey::kYes].ThereIs; |
1356 | 1358 | ||
1357 | 1359 | ||
1358 | #ifndef _NO_CRYPTO | 1360 | #ifndef Z7_NO_CRYPTO |
1359 | options.PasswordEnabled = parser[NKey::kPassword].ThereIs; | 1361 | options.PasswordEnabled = parser[NKey::kPassword].ThereIs; |
1360 | if (options.PasswordEnabled) | 1362 | if (options.PasswordEnabled) |
1361 | options.Password = parser[NKey::kPassword].PostStrings[0]; | 1363 | options.Password = parser[NKey::kPassword].PostStrings[0]; |
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.h b/CPP/7zip/UI/Common/ArchiveCommandLine.h index 745f999..9e375b5 100644 --- a/CPP/7zip/UI/Common/ArchiveCommandLine.h +++ b/CPP/7zip/UI/Common/ArchiveCommandLine.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // ArchiveCommandLine.h | 1 | // ArchiveCommandLine.h |
2 | 2 | ||
3 | #ifndef __ARCHIVE_COMMAND_LINE_H | 3 | #ifndef ZIP7_INC_ARCHIVE_COMMAND_LINE_H |
4 | #define __ARCHIVE_COMMAND_LINE_H | 4 | #define ZIP7_INC_ARCHIVE_COMMAND_LINE_H |
5 | 5 | ||
6 | #include "../../../Common/CommandLineParser.h" | 6 | #include "../../../Common/CommandLineParser.h" |
7 | #include "../../../Common/Wildcard.h" | 7 | #include "../../../Common/Wildcard.h" |
@@ -66,6 +66,14 @@ struct CArcCmdLineOptions | |||
66 | bool TechMode; | 66 | bool TechMode; |
67 | bool ShowTime; | 67 | bool ShowTime; |
68 | 68 | ||
69 | CBoolPair NtSecurity; | ||
70 | CBoolPair AltStreams; | ||
71 | CBoolPair HardLinks; | ||
72 | CBoolPair SymLinks; | ||
73 | |||
74 | CBoolPair StoreOwnerId; | ||
75 | CBoolPair StoreOwnerName; | ||
76 | |||
69 | AString ListFields; | 77 | AString ListFields; |
70 | 78 | ||
71 | int ConsoleCodePage; | 79 | int ConsoleCodePage; |
@@ -75,7 +83,7 @@ struct CArcCmdLineOptions | |||
75 | CArcCommand Command; | 83 | CArcCommand Command; |
76 | UString ArchiveName; | 84 | UString ArchiveName; |
77 | 85 | ||
78 | #ifndef _NO_CRYPTO | 86 | #ifndef Z7_NO_CRYPTO |
79 | bool PasswordEnabled; | 87 | bool PasswordEnabled; |
80 | UString Password; | 88 | UString Password; |
81 | #endif | 89 | #endif |
@@ -83,7 +91,7 @@ struct CArcCmdLineOptions | |||
83 | UStringVector HashMethods; | 91 | UStringVector HashMethods; |
84 | // UString HashFilePath; | 92 | // UString HashFilePath; |
85 | 93 | ||
86 | bool AppendName; | 94 | // bool AppendName; |
87 | // UStringVector ArchivePathsSorted; | 95 | // UStringVector ArchivePathsSorted; |
88 | // UStringVector ArchivePathsFullSorted; | 96 | // UStringVector ArchivePathsFullSorted; |
89 | NWildcard::CCensor arcCensor; | 97 | NWildcard::CCensor arcCensor; |
@@ -93,14 +101,6 @@ struct CArcCmdLineOptions | |||
93 | 101 | ||
94 | CExtractOptionsBase ExtractOptions; | 102 | CExtractOptionsBase ExtractOptions; |
95 | 103 | ||
96 | CBoolPair NtSecurity; | ||
97 | CBoolPair AltStreams; | ||
98 | CBoolPair HardLinks; | ||
99 | CBoolPair SymLinks; | ||
100 | |||
101 | CBoolPair StoreOwnerId; | ||
102 | CBoolPair StoreOwnerName; | ||
103 | |||
104 | CUpdateOptions UpdateOptions; | 104 | CUpdateOptions UpdateOptions; |
105 | CHashOptions HashOptions; | 105 | CHashOptions HashOptions; |
106 | UString ArcType; | 106 | UString ArcType; |
@@ -145,7 +145,7 @@ struct CArcCmdLineOptions | |||
145 | 145 | ||
146 | LogLevel(0) | 146 | LogLevel(0) |
147 | { | 147 | { |
148 | }; | 148 | } |
149 | }; | 149 | }; |
150 | 150 | ||
151 | class CArcCmdLineParser | 151 | class CArcCmdLineParser |
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp index a574f13..4b0cbed 100644 --- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp +++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp | |||
@@ -25,8 +25,8 @@ | |||
25 | #include "../../../Windows/PropVariant.h" | 25 | #include "../../../Windows/PropVariant.h" |
26 | #include "../../../Windows/PropVariantConv.h" | 26 | #include "../../../Windows/PropVariantConv.h" |
27 | 27 | ||
28 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(_SFX) | 28 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX) |
29 | #define _USE_SECURITY_CODE | 29 | #define Z7_USE_SECURITY_CODE |
30 | #include "../../../Windows/SecurityUtils.h" | 30 | #include "../../../Windows/SecurityUtils.h" |
31 | #endif | 31 | #endif |
32 | 32 | ||
@@ -54,9 +54,9 @@ static const char * const kCantCreateHardLink = "Cannot create hard link"; | |||
54 | static const char * const kCantCreateSymLink = "Cannot create symbolic link"; | 54 | static const char * const kCantCreateSymLink = "Cannot create symbolic link"; |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #ifndef _SFX | 57 | #ifndef Z7_SFX |
58 | 58 | ||
59 | STDMETHODIMP COutStreamWithHash::Write(const void *data, UInt32 size, UInt32 *processedSize) | 59 | Z7_COM7F_IMF(COutStreamWithHash::Write(const void *data, UInt32 size, UInt32 *processedSize)) |
60 | { | 60 | { |
61 | HRESULT result = S_OK; | 61 | HRESULT result = S_OK; |
62 | if (_stream) | 62 | if (_stream) |
@@ -69,10 +69,10 @@ STDMETHODIMP COutStreamWithHash::Write(const void *data, UInt32 size, UInt32 *pr | |||
69 | return result; | 69 | return result; |
70 | } | 70 | } |
71 | 71 | ||
72 | #endif // _SFX | 72 | #endif // Z7_SFX |
73 | 73 | ||
74 | 74 | ||
75 | #ifdef _USE_SECURITY_CODE | 75 | #ifdef Z7_USE_SECURITY_CODE |
76 | bool InitLocalPrivileges(); | 76 | bool InitLocalPrivileges(); |
77 | bool InitLocalPrivileges() | 77 | bool InitLocalPrivileges() |
78 | { | 78 | { |
@@ -92,11 +92,11 @@ bool InitLocalPrivileges() | |||
92 | return false; | 92 | return false; |
93 | return (GetLastError() == ERROR_SUCCESS); | 93 | return (GetLastError() == ERROR_SUCCESS); |
94 | } | 94 | } |
95 | #endif // _USE_SECURITY_CODE | 95 | #endif // Z7_USE_SECURITY_CODE |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
99 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(_SFX) | 99 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX) |
100 | 100 | ||
101 | static const char * const kOfficeExtensions = | 101 | static const char * const kOfficeExtensions = |
102 | " doc dot wbk" | 102 | " doc dot wbk" |
@@ -117,7 +117,7 @@ static bool FindExt2(const char *p, const UString &name) | |||
117 | return false; | 117 | return false; |
118 | 118 | ||
119 | AString s; | 119 | AString s; |
120 | for (unsigned pos = dotPos + 1;; pos++) | 120 | for (unsigned pos = (unsigned)(dotPos + 1);; pos++) |
121 | { | 121 | { |
122 | const wchar_t c = name[pos]; | 122 | const wchar_t c = name[pos]; |
123 | if (c <= 0) | 123 | if (c <= 0) |
@@ -142,7 +142,7 @@ static const FChar * const k_ZoneId_StreamName = FTEXT(":Zone.Identifier"); | |||
142 | 142 | ||
143 | void ReadZoneFile_Of_BaseFile(CFSTR fileName2, CByteBuffer &buf) | 143 | void ReadZoneFile_Of_BaseFile(CFSTR fileName2, CByteBuffer &buf) |
144 | { | 144 | { |
145 | FString fileName = fileName2; | 145 | FString fileName (fileName2); |
146 | fileName += k_ZoneId_StreamName; | 146 | fileName += k_ZoneId_StreamName; |
147 | 147 | ||
148 | buf.Free(); | 148 | buf.Free(); |
@@ -188,13 +188,13 @@ static HRESULT Archive_Get_HardLinkNode(IInArchive *archive, UInt32 index, CHard | |||
188 | defined = false; | 188 | defined = false; |
189 | { | 189 | { |
190 | NCOM::CPropVariant prop; | 190 | NCOM::CPropVariant prop; |
191 | RINOK(archive->GetProperty(index, kpidINode, &prop)); | 191 | RINOK(archive->GetProperty(index, kpidINode, &prop)) |
192 | if (!ConvertPropVariantToUInt64(prop, h.INode)) | 192 | if (!ConvertPropVariantToUInt64(prop, h.INode)) |
193 | return S_OK; | 193 | return S_OK; |
194 | } | 194 | } |
195 | { | 195 | { |
196 | NCOM::CPropVariant prop; | 196 | NCOM::CPropVariant prop; |
197 | RINOK(archive->GetProperty(index, kpidStreamId, &prop)); | 197 | RINOK(archive->GetProperty(index, kpidStreamId, &prop)) |
198 | ConvertPropVariantToUInt64(prop, h.StreamId); | 198 | ConvertPropVariantToUInt64(prop, h.StreamId); |
199 | } | 199 | } |
200 | defined = true; | 200 | defined = true; |
@@ -218,22 +218,27 @@ HRESULT CArchiveExtractCallback::PrepareHardLinks(const CRecordVector<UInt32> *r | |||
218 | numItems = realIndices->Size(); | 218 | numItems = realIndices->Size(); |
219 | else | 219 | else |
220 | { | 220 | { |
221 | RINOK(archive->GetNumberOfItems(&numItems)); | 221 | RINOK(archive->GetNumberOfItems(&numItems)) |
222 | } | 222 | } |
223 | 223 | ||
224 | for (UInt32 i = 0; i < numItems; i++) | 224 | for (UInt32 i = 0; i < numItems; i++) |
225 | { | 225 | { |
226 | CHardLinkNode h; | 226 | CHardLinkNode h; |
227 | bool defined; | 227 | bool defined; |
228 | UInt32 realIndex = realIndices ? (*realIndices)[i] : i; | 228 | const UInt32 realIndex = realIndices ? (*realIndices)[i] : i; |
229 | 229 | ||
230 | RINOK(Archive_Get_HardLinkNode(archive, realIndex, h, defined)); | 230 | RINOK(Archive_Get_HardLinkNode(archive, realIndex, h, defined)) |
231 | if (defined) | 231 | if (defined) |
232 | { | 232 | { |
233 | bool isAltStream = false; | 233 | bool isAltStream = false; |
234 | RINOK(Archive_IsItem_AltStream(archive, realIndex, isAltStream)); | 234 | RINOK(Archive_IsItem_AltStream(archive, realIndex, isAltStream)) |
235 | if (!isAltStream) | 235 | if (!isAltStream) |
236 | hardIDs.Add(h); | 236 | { |
237 | bool isDir = false; | ||
238 | RINOK(Archive_IsItem_Dir(archive, realIndex, isDir)) | ||
239 | if (!isDir) | ||
240 | hardIDs.Add(h); | ||
241 | } | ||
237 | } | 242 | } |
238 | } | 243 | } |
239 | } | 244 | } |
@@ -275,7 +280,7 @@ CArchiveExtractCallback::CArchiveExtractCallback(): | |||
275 | LocalProgressSpec = new CLocalProgress(); | 280 | LocalProgressSpec = new CLocalProgress(); |
276 | _localProgress = LocalProgressSpec; | 281 | _localProgress = LocalProgressSpec; |
277 | 282 | ||
278 | #ifdef _USE_SECURITY_CODE | 283 | #ifdef Z7_USE_SECURITY_CODE |
279 | _saclEnabled = InitLocalPrivileges(); | 284 | _saclEnabled = InitLocalPrivileges(); |
280 | #endif | 285 | #endif |
281 | } | 286 | } |
@@ -325,16 +330,18 @@ void CArchiveExtractCallback::Init( | |||
325 | 330 | ||
326 | _extractCallback2 = extractCallback2; | 331 | _extractCallback2 = extractCallback2; |
327 | 332 | ||
333 | /* | ||
328 | _compressProgress.Release(); | 334 | _compressProgress.Release(); |
329 | _extractCallback2.QueryInterface(IID_ICompressProgressInfo, &_compressProgress); | 335 | _extractCallback2.QueryInterface(IID_ICompressProgressInfo, &_compressProgress); |
330 | 336 | ||
331 | _callbackMessage.Release(); | 337 | _callbackMessage.Release(); |
332 | _extractCallback2.QueryInterface(IID_IArchiveExtractCallbackMessage, &_callbackMessage); | 338 | _extractCallback2.QueryInterface(IID_IArchiveExtractCallbackMessage2, &_callbackMessage); |
339 | */ | ||
333 | 340 | ||
334 | _folderArchiveExtractCallback2.Release(); | 341 | _folderArchiveExtractCallback2.Release(); |
335 | _extractCallback2.QueryInterface(IID_IFolderArchiveExtractCallback2, &_folderArchiveExtractCallback2); | 342 | _extractCallback2.QueryInterface(IID_IFolderArchiveExtractCallback2, &_folderArchiveExtractCallback2); |
336 | 343 | ||
337 | #ifndef _SFX | 344 | #ifndef Z7_SFX |
338 | 345 | ||
339 | ExtractToStreamCallback.Release(); | 346 | ExtractToStreamCallback.Release(); |
340 | _extractCallback2.QueryInterface(IID_IFolderExtractToStreamCallback, &ExtractToStreamCallback); | 347 | _extractCallback2.QueryInterface(IID_IFolderExtractToStreamCallback, &ExtractToStreamCallback); |
@@ -355,7 +362,7 @@ void CArchiveExtractCallback::Init( | |||
355 | _removePathParts = removePathParts; | 362 | _removePathParts = removePathParts; |
356 | _removePartsForAltStreams = removePartsForAltStreams; | 363 | _removePartsForAltStreams = removePartsForAltStreams; |
357 | 364 | ||
358 | #ifndef _SFX | 365 | #ifndef Z7_SFX |
359 | _baseParentFolder = (UInt32)(Int32)-1; | 366 | _baseParentFolder = (UInt32)(Int32)-1; |
360 | _use_baseParentFolder_mode = false; | 367 | _use_baseParentFolder_mode = false; |
361 | #endif | 368 | #endif |
@@ -374,7 +381,7 @@ void CArchiveExtractCallback::Init( | |||
374 | } | 381 | } |
375 | 382 | ||
376 | 383 | ||
377 | STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 size) | 384 | Z7_COM7F_IMF(CArchiveExtractCallback::SetTotal(UInt64 size)) |
378 | { | 385 | { |
379 | COM_TRY_BEGIN | 386 | COM_TRY_BEGIN |
380 | _progressTotal = size; | 387 | _progressTotal = size; |
@@ -407,7 +414,7 @@ static UInt64 MyMultDiv64(UInt64 unpCur, UInt64 unpTotal, UInt64 packTotal) | |||
407 | } | 414 | } |
408 | 415 | ||
409 | 416 | ||
410 | STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue) | 417 | Z7_COM7F_IMF(CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue)) |
411 | { | 418 | { |
412 | COM_TRY_BEGIN | 419 | COM_TRY_BEGIN |
413 | 420 | ||
@@ -428,7 +435,7 @@ STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue) | |||
428 | } | 435 | } |
429 | 436 | ||
430 | 437 | ||
431 | STDMETHODIMP CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) | 438 | Z7_COM7F_IMF(CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)) |
432 | { | 439 | { |
433 | COM_TRY_BEGIN | 440 | COM_TRY_BEGIN |
434 | return _localProgress->SetRatioInfo(inSize, outSize); | 441 | return _localProgress->SetRatioInfo(inSize, outSize); |
@@ -510,7 +517,7 @@ HRESULT CArchiveExtractCallback::GetTime(UInt32 index, PROPID propID, CArcTime & | |||
510 | { | 517 | { |
511 | ft.Clear(); | 518 | ft.Clear(); |
512 | NCOM::CPropVariant prop; | 519 | NCOM::CPropVariant prop; |
513 | RINOK(_arc->Archive->GetProperty(index, propID, &prop)); | 520 | RINOK(_arc->Archive->GetProperty(index, propID, &prop)) |
514 | if (prop.vt == VT_FILETIME) | 521 | if (prop.vt == VT_FILETIME) |
515 | ft.Set_From_Prop(prop); | 522 | ft.Set_From_Prop(prop); |
516 | else if (prop.vt != VT_EMPTY) | 523 | else if (prop.vt != VT_EMPTY) |
@@ -521,7 +528,7 @@ HRESULT CArchiveExtractCallback::GetTime(UInt32 index, PROPID propID, CArcTime & | |||
521 | 528 | ||
522 | HRESULT CArchiveExtractCallback::GetUnpackSize() | 529 | HRESULT CArchiveExtractCallback::GetUnpackSize() |
523 | { | 530 | { |
524 | return _arc->GetItem_Size(_index, _curSize, _curSizeDefined); | 531 | return _arc->GetItem_Size(_index, _curSize, _curSize_Defined); |
525 | } | 532 | } |
526 | 533 | ||
527 | static void AddPathToMessage(UString &s, const FString &path) | 534 | static void AddPathToMessage(UString &s, const FString &path) |
@@ -564,9 +571,9 @@ HRESULT CArchiveExtractCallback::SendMessageError2(HRESULT errorCode, const char | |||
564 | return _extractCallback2->MessageError(s); | 571 | return _extractCallback2->MessageError(s); |
565 | } | 572 | } |
566 | 573 | ||
567 | #ifndef _SFX | 574 | #ifndef Z7_SFX |
568 | 575 | ||
569 | STDMETHODIMP CGetProp::GetProp(PROPID propID, PROPVARIANT *value) | 576 | Z7_COM7F_IMF(CGetProp::GetProp(PROPID propID, PROPVARIANT *value)) |
570 | { | 577 | { |
571 | /* | 578 | /* |
572 | if (propID == kpidName) | 579 | if (propID == kpidName) |
@@ -581,7 +588,7 @@ STDMETHODIMP CGetProp::GetProp(PROPID propID, PROPVARIANT *value) | |||
581 | return Arc->Archive->GetProperty(IndexInArc, propID, value); | 588 | return Arc->Archive->GetProperty(IndexInArc, propID, value); |
582 | } | 589 | } |
583 | 590 | ||
584 | #endif // _SFX | 591 | #endif // Z7_SFX |
585 | 592 | ||
586 | 593 | ||
587 | #ifdef SUPPORT_LINKS | 594 | #ifdef SUPPORT_LINKS |
@@ -749,15 +756,15 @@ HRESULT CArchiveExtractCallback::MyCopyFile(ISequentialOutStream *outStream) | |||
749 | NIO::CInFile inFile; | 756 | NIO::CInFile inFile; |
750 | NIO::COutFile outFile; | 757 | NIO::COutFile outFile; |
751 | 758 | ||
752 | if (!inFile.Open(_CopyFile_Path)) | 759 | if (!inFile.Open(_copyFile_Path)) |
753 | return SendMessageError_with_LastError("Open error", _CopyFile_Path); | 760 | return SendMessageError_with_LastError("Open error", _copyFile_Path); |
754 | 761 | ||
755 | for (;;) | 762 | for (;;) |
756 | { | 763 | { |
757 | UInt32 num; | 764 | UInt32 num; |
758 | 765 | ||
759 | if (!inFile.Read(buf.Buf, kBufSize, num)) | 766 | if (!inFile.Read(buf.Buf, kBufSize, num)) |
760 | return SendMessageError_with_LastError("Read error", _CopyFile_Path); | 767 | return SendMessageError_with_LastError("Read error", _copyFile_Path); |
761 | 768 | ||
762 | if (num == 0) | 769 | if (num == 0) |
763 | return S_OK; | 770 | return S_OK; |
@@ -777,7 +784,7 @@ HRESULT CArchiveExtractCallback::ReadLink() | |||
777 | 784 | ||
778 | { | 785 | { |
779 | NCOM::CPropVariant prop; | 786 | NCOM::CPropVariant prop; |
780 | RINOK(archive->GetProperty(index, kpidHardLink, &prop)); | 787 | RINOK(archive->GetProperty(index, kpidHardLink, &prop)) |
781 | if (prop.vt == VT_BSTR) | 788 | if (prop.vt == VT_BSTR) |
782 | { | 789 | { |
783 | _link.isHardLink = true; | 790 | _link.isHardLink = true; |
@@ -807,7 +814,7 @@ HRESULT CArchiveExtractCallback::ReadLink() | |||
807 | 814 | ||
808 | { | 815 | { |
809 | NCOM::CPropVariant prop; | 816 | NCOM::CPropVariant prop; |
810 | RINOK(archive->GetProperty(index, kpidSymLink, &prop)); | 817 | RINOK(archive->GetProperty(index, kpidSymLink, &prop)) |
811 | if (prop.vt == VT_BSTR) | 818 | if (prop.vt == VT_BSTR) |
812 | { | 819 | { |
813 | _link.isHardLink = false; | 820 | _link.isHardLink = false; |
@@ -937,7 +944,7 @@ static HRESULT GetOwner(IInArchive *archive, | |||
937 | { | 944 | { |
938 | { | 945 | { |
939 | NWindows::NCOM::CPropVariant prop; | 946 | NWindows::NCOM::CPropVariant prop; |
940 | RINOK(archive->GetProperty(index, pidId, &prop)); | 947 | RINOK(archive->GetProperty(index, pidId, &prop)) |
941 | if (prop.vt == VT_UI4) | 948 | if (prop.vt == VT_UI4) |
942 | { | 949 | { |
943 | res.Id_Defined = true; | 950 | res.Id_Defined = true; |
@@ -951,7 +958,7 @@ static HRESULT GetOwner(IInArchive *archive, | |||
951 | } | 958 | } |
952 | { | 959 | { |
953 | NWindows::NCOM::CPropVariant prop; | 960 | NWindows::NCOM::CPropVariant prop; |
954 | RINOK(archive->GetProperty(index, pidName, &prop)); | 961 | RINOK(archive->GetProperty(index, pidName, &prop)) |
955 | if (prop.vt == VT_BSTR) | 962 | if (prop.vt == VT_BSTR) |
956 | { | 963 | { |
957 | const UString s = prop.bstrVal; | 964 | const UString s = prop.bstrVal; |
@@ -981,11 +988,11 @@ HRESULT CArchiveExtractCallback::Read_fi_Props() | |||
981 | #ifndef _WIN32 | 988 | #ifndef _WIN32 |
982 | _fi.Owner.Clear(); | 989 | _fi.Owner.Clear(); |
983 | _fi.Group.Clear(); | 990 | _fi.Group.Clear(); |
984 | #endif | 991 | #endif |
985 | 992 | ||
986 | { | 993 | { |
987 | NCOM::CPropVariant prop; | 994 | NCOM::CPropVariant prop; |
988 | RINOK(archive->GetProperty(index, kpidPosixAttrib, &prop)); | 995 | RINOK(archive->GetProperty(index, kpidPosixAttrib, &prop)) |
989 | if (prop.vt == VT_UI4) | 996 | if (prop.vt == VT_UI4) |
990 | { | 997 | { |
991 | _fi.SetFromPosixAttrib(prop.ulVal); | 998 | _fi.SetFromPosixAttrib(prop.ulVal); |
@@ -996,7 +1003,7 @@ HRESULT CArchiveExtractCallback::Read_fi_Props() | |||
996 | 1003 | ||
997 | { | 1004 | { |
998 | NCOM::CPropVariant prop; | 1005 | NCOM::CPropVariant prop; |
999 | RINOK(archive->GetProperty(index, kpidAttrib, &prop)); | 1006 | RINOK(archive->GetProperty(index, kpidAttrib, &prop)) |
1000 | if (prop.vt == VT_UI4) | 1007 | if (prop.vt == VT_UI4) |
1001 | { | 1008 | { |
1002 | _fi.Attrib = prop.ulVal; | 1009 | _fi.Attrib = prop.ulVal; |
@@ -1006,9 +1013,9 @@ HRESULT CArchiveExtractCallback::Read_fi_Props() | |||
1006 | return E_FAIL; | 1013 | return E_FAIL; |
1007 | } | 1014 | } |
1008 | 1015 | ||
1009 | RINOK(GetTime(index, kpidCTime, _fi.CTime)); | 1016 | RINOK(GetTime(index, kpidCTime, _fi.CTime)) |
1010 | RINOK(GetTime(index, kpidATime, _fi.ATime)); | 1017 | RINOK(GetTime(index, kpidATime, _fi.ATime)) |
1011 | RINOK(GetTime(index, kpidMTime, _fi.MTime)); | 1018 | RINOK(GetTime(index, kpidMTime, _fi.MTime)) |
1012 | 1019 | ||
1013 | #ifndef _WIN32 | 1020 | #ifndef _WIN32 |
1014 | if (_ntOptions.ExtractOwner) | 1021 | if (_ntOptions.ExtractOwner) |
@@ -1104,9 +1111,19 @@ void CArchiveExtractCallback::CreateFolders() | |||
1104 | // 21.04 : we don't change original (_item.PathParts) here | 1111 | // 21.04 : we don't change original (_item.PathParts) here |
1105 | UStringVector pathParts = _item.PathParts; | 1112 | UStringVector pathParts = _item.PathParts; |
1106 | 1113 | ||
1107 | if (!_item.IsDir) | 1114 | if (!pathParts.IsEmpty()) |
1108 | { | 1115 | { |
1109 | if (!pathParts.IsEmpty()) | 1116 | /* v23: if we extract symlink, and we know that it links to dir: |
1117 | Linux: we don't create dir item (symlink_from_path) here. | ||
1118 | Windows: SetReparseData() will create dir item, if it doesn't exist, | ||
1119 | but if we create dir item here, it's not problem. */ | ||
1120 | if (!_item.IsDir | ||
1121 | #ifdef SUPPORT_LINKS | ||
1122 | #ifndef WIN32 | ||
1123 | || !_link.linkPath.IsEmpty() | ||
1124 | #endif | ||
1125 | #endif | ||
1126 | ) | ||
1110 | pathParts.DeleteBack(); | 1127 | pathParts.DeleteBack(); |
1111 | } | 1128 | } |
1112 | 1129 | ||
@@ -1167,7 +1184,7 @@ HRESULT CArchiveExtractCallback::CheckExistFile(FString &fullProcessedPath, bool | |||
1167 | RINOK(_extractCallback2->AskOverwrite( | 1184 | RINOK(_extractCallback2->AskOverwrite( |
1168 | fs2us(realFullProcessedPath), &ft1, &fileInfo.Size, _item.Path, | 1185 | fs2us(realFullProcessedPath), &ft1, &fileInfo.Size, _item.Path, |
1169 | _fi.MTime.Def ? &_fi.MTime.FT : NULL, | 1186 | _fi.MTime.Def ? &_fi.MTime.FT : NULL, |
1170 | _curSizeDefined ? &_curSize : NULL, | 1187 | _curSize_Defined ? &_curSize : NULL, |
1171 | &overwriteResult)) | 1188 | &overwriteResult)) |
1172 | 1189 | ||
1173 | switch (overwriteResult) | 1190 | switch (overwriteResult) |
@@ -1197,7 +1214,7 @@ HRESULT CArchiveExtractCallback::CheckExistFile(FString &fullProcessedPath, bool | |||
1197 | { | 1214 | { |
1198 | if (!AutoRenamePath(fullProcessedPath)) | 1215 | if (!AutoRenamePath(fullProcessedPath)) |
1199 | { | 1216 | { |
1200 | RINOK(SendMessageError(kCantAutoRename, fullProcessedPath)); | 1217 | RINOK(SendMessageError(kCantAutoRename, fullProcessedPath)) |
1201 | return E_FAIL; | 1218 | return E_FAIL; |
1202 | } | 1219 | } |
1203 | _isRenamed = true; | 1220 | _isRenamed = true; |
@@ -1207,14 +1224,14 @@ HRESULT CArchiveExtractCallback::CheckExistFile(FString &fullProcessedPath, bool | |||
1207 | FString existPath (fullProcessedPath); | 1224 | FString existPath (fullProcessedPath); |
1208 | if (!AutoRenamePath(existPath)) | 1225 | if (!AutoRenamePath(existPath)) |
1209 | { | 1226 | { |
1210 | RINOK(SendMessageError(kCantAutoRename, fullProcessedPath)); | 1227 | RINOK(SendMessageError(kCantAutoRename, fullProcessedPath)) |
1211 | return E_FAIL; | 1228 | return E_FAIL; |
1212 | } | 1229 | } |
1213 | // MyMoveFile can rename folders. So it's OK to use it for folders too | 1230 | // MyMoveFile can rename folders. So it's OK to use it for folders too |
1214 | if (!MyMoveFile(fullProcessedPath, existPath)) | 1231 | if (!MyMoveFile(fullProcessedPath, existPath)) |
1215 | { | 1232 | { |
1216 | HRESULT errorCode = GetLastError_noZero_HRESULT(); | 1233 | HRESULT errorCode = GetLastError_noZero_HRESULT(); |
1217 | RINOK(SendMessageError2(errorCode, kCantRenameFile, existPath, fullProcessedPath)); | 1234 | RINOK(SendMessageError2(errorCode, kCantRenameFile, existPath, fullProcessedPath)) |
1218 | return E_FAIL; | 1235 | return E_FAIL; |
1219 | } | 1236 | } |
1220 | } | 1237 | } |
@@ -1225,7 +1242,7 @@ HRESULT CArchiveExtractCallback::CheckExistFile(FString &fullProcessedPath, bool | |||
1225 | // do we need to delete all files in folder? | 1242 | // do we need to delete all files in folder? |
1226 | if (!RemoveDir(fullProcessedPath)) | 1243 | if (!RemoveDir(fullProcessedPath)) |
1227 | { | 1244 | { |
1228 | RINOK(SendMessageError_with_LastError(kCantDeleteOutputDir, fullProcessedPath)); | 1245 | RINOK(SendMessageError_with_LastError(kCantDeleteOutputDir, fullProcessedPath)) |
1229 | return S_OK; | 1246 | return S_OK; |
1230 | } | 1247 | } |
1231 | } | 1248 | } |
@@ -1235,7 +1252,7 @@ HRESULT CArchiveExtractCallback::CheckExistFile(FString &fullProcessedPath, bool | |||
1235 | if (!DeleteFileAlways(fullProcessedPath)) | 1252 | if (!DeleteFileAlways(fullProcessedPath)) |
1236 | if (GetLastError() != ERROR_FILE_NOT_FOUND) // check it in linux | 1253 | if (GetLastError() != ERROR_FILE_NOT_FOUND) // check it in linux |
1237 | { | 1254 | { |
1238 | RINOK(SendMessageError_with_LastError(kCantDeleteOutputFile, fullProcessedPath)); | 1255 | RINOK(SendMessageError_with_LastError(kCantDeleteOutputFile, fullProcessedPath)) |
1239 | return S_OK; | 1256 | return S_OK; |
1240 | // return E_FAIL; | 1257 | // return E_FAIL; |
1241 | } | 1258 | } |
@@ -1274,7 +1291,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1274 | { | 1291 | { |
1275 | needExit = true; | 1292 | needExit = true; |
1276 | 1293 | ||
1277 | RINOK(Read_fi_Props()); | 1294 | RINOK(Read_fi_Props()) |
1278 | 1295 | ||
1279 | #ifdef SUPPORT_LINKS | 1296 | #ifdef SUPPORT_LINKS |
1280 | IInArchive *archive = _arc->Archive; | 1297 | IInArchive *archive = _arc->Archive; |
@@ -1283,7 +1300,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1283 | const UInt32 index = _index; | 1300 | const UInt32 index = _index; |
1284 | 1301 | ||
1285 | bool isAnti = false; | 1302 | bool isAnti = false; |
1286 | RINOK(_arc->IsItem_Anti(index, isAnti)); | 1303 | RINOK(_arc->IsItem_Anti(index, isAnti)) |
1287 | 1304 | ||
1288 | CorrectPathParts(); | 1305 | CorrectPathParts(); |
1289 | UString processedPath (MakePathFromParts(_item.PathParts)); | 1306 | UString processedPath (MakePathFromParts(_item.PathParts)); |
@@ -1333,7 +1350,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1333 | } | 1350 | } |
1334 | else if (!_isSplit) | 1351 | else if (!_isSplit) |
1335 | { | 1352 | { |
1336 | RINOK(CheckExistFile(fullProcessedPath, needExit)); | 1353 | RINOK(CheckExistFile(fullProcessedPath, needExit)) |
1337 | if (needExit) | 1354 | if (needExit) |
1338 | return S_OK; | 1355 | return S_OK; |
1339 | needExit = true; | 1356 | needExit = true; |
@@ -1357,7 +1374,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1357 | #ifndef UNDER_CE | 1374 | #ifndef UNDER_CE |
1358 | { | 1375 | { |
1359 | bool linkWasSet = false; | 1376 | bool linkWasSet = false; |
1360 | RINOK(SetFromLinkPath(fullProcessedPath, _link, linkWasSet)); | 1377 | RINOK(SetFromLinkPath(fullProcessedPath, _link, linkWasSet)) |
1361 | if (linkWasSet) | 1378 | if (linkWasSet) |
1362 | { | 1379 | { |
1363 | _isSymLinkCreated = _link.IsSymLink(); | 1380 | _isSymLinkCreated = _link.IsSymLink(); |
@@ -1367,18 +1384,18 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1367 | } | 1384 | } |
1368 | #endif // UNDER_CE | 1385 | #endif // UNDER_CE |
1369 | 1386 | ||
1370 | // if (_CopyFile_Path.IsEmpty()) | 1387 | // if (_copyFile_Path.IsEmpty()) |
1371 | { | 1388 | { |
1372 | needExit = false; | 1389 | needExit = false; |
1373 | return S_OK; | 1390 | return S_OK; |
1374 | } | 1391 | } |
1375 | } | 1392 | } |
1376 | 1393 | ||
1377 | if (!_hardLinks.IDs.IsEmpty() && !_item.IsAltStream) | 1394 | if (!_hardLinks.IDs.IsEmpty() && !_item.IsAltStream && !_item.IsDir) |
1378 | { | 1395 | { |
1379 | CHardLinkNode h; | 1396 | CHardLinkNode h; |
1380 | bool defined; | 1397 | bool defined; |
1381 | RINOK(Archive_Get_HardLinkNode(archive, index, h, defined)); | 1398 | RINOK(Archive_Get_HardLinkNode(archive, index, h, defined)) |
1382 | if (defined) | 1399 | if (defined) |
1383 | { | 1400 | { |
1384 | const int linkIndex = _hardLinks.IDs.FindInSorted2(h); | 1401 | const int linkIndex = _hardLinks.IDs.FindInSorted2(h); |
@@ -1392,7 +1409,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1392 | if (!MyCreateHardLink(fullProcessedPath, hl)) | 1409 | if (!MyCreateHardLink(fullProcessedPath, hl)) |
1393 | { | 1410 | { |
1394 | HRESULT errorCode = GetLastError_noZero_HRESULT(); | 1411 | HRESULT errorCode = GetLastError_noZero_HRESULT(); |
1395 | RINOK(SendMessageError2(errorCode, kCantCreateHardLink, fullProcessedPath, hl)); | 1412 | RINOK(SendMessageError2(errorCode, kCantCreateHardLink, fullProcessedPath, hl)) |
1396 | return S_OK; | 1413 | return S_OK; |
1397 | } | 1414 | } |
1398 | 1415 | ||
@@ -1412,13 +1429,13 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1412 | // ---------- CREATE WRITE FILE ----- | 1429 | // ---------- CREATE WRITE FILE ----- |
1413 | 1430 | ||
1414 | _outFileStreamSpec = new COutFileStream; | 1431 | _outFileStreamSpec = new COutFileStream; |
1415 | CMyComPtr<ISequentialOutStream> outFileStream_Loc(_outFileStreamSpec); | 1432 | CMyComPtr<IOutStream> outFileStream_Loc(_outFileStreamSpec); |
1416 | 1433 | ||
1417 | if (!_outFileStreamSpec->Open(fullProcessedPath, _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS)) | 1434 | if (!_outFileStreamSpec->Open(fullProcessedPath, _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS)) |
1418 | { | 1435 | { |
1419 | // if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit) | 1436 | // if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit) |
1420 | { | 1437 | { |
1421 | RINOK(SendMessageError_with_LastError(kCantOpenOutFile, fullProcessedPath)); | 1438 | RINOK(SendMessageError_with_LastError(kCantOpenOutFile, fullProcessedPath)) |
1422 | return S_OK; | 1439 | return S_OK; |
1423 | } | 1440 | } |
1424 | } | 1441 | } |
@@ -1427,7 +1444,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1427 | 1444 | ||
1428 | bool is_SymLink_in_Data = false; | 1445 | bool is_SymLink_in_Data = false; |
1429 | 1446 | ||
1430 | if (_curSizeDefined && _curSize > 0 && _curSize < (1 << 12)) | 1447 | if (_curSize_Defined && _curSize > 0 && _curSize < (1 << 12)) |
1431 | { | 1448 | { |
1432 | if (_fi.IsLinuxSymLink()) | 1449 | if (_fi.IsLinuxSymLink()) |
1433 | { | 1450 | { |
@@ -1451,18 +1468,18 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1451 | } | 1468 | } |
1452 | else // not reprase | 1469 | else // not reprase |
1453 | { | 1470 | { |
1454 | if (_ntOptions.PreAllocateOutFile && !_isSplit && _curSizeDefined && _curSize > (1 << 12)) | 1471 | if (_ntOptions.PreAllocateOutFile && !_isSplit && _curSize_Defined && _curSize > (1 << 12)) |
1455 | { | 1472 | { |
1456 | // UInt64 ticks = GetCpuTicks(); | 1473 | // UInt64 ticks = GetCpuTicks(); |
1457 | _fileLength_that_WasSet = _curSize; | 1474 | _fileLength_that_WasSet = _curSize; |
1458 | bool res = _outFileStreamSpec->File.SetLength(_curSize); | 1475 | bool res = _outFileStreamSpec->File.SetLength(_curSize); |
1459 | _fileLengthWasSet = res; | 1476 | _fileLength_WasSet = res; |
1460 | 1477 | ||
1461 | // ticks = GetCpuTicks() - ticks; | 1478 | // ticks = GetCpuTicks() - ticks; |
1462 | // printf("\nticks = %10d\n", (unsigned)ticks); | 1479 | // printf("\nticks = %10d\n", (unsigned)ticks); |
1463 | if (!res) | 1480 | if (!res) |
1464 | { | 1481 | { |
1465 | RINOK(SendMessageError_with_LastError(kCantSetFileLen, fullProcessedPath)); | 1482 | RINOK(SendMessageError_with_LastError(kCantSetFileLen, fullProcessedPath)) |
1466 | } | 1483 | } |
1467 | 1484 | ||
1468 | /* | 1485 | /* |
@@ -1484,7 +1501,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1484 | res = _outFileStreamSpec->SeekToBegin_bool(); | 1501 | res = _outFileStreamSpec->SeekToBegin_bool(); |
1485 | if (!res) | 1502 | if (!res) |
1486 | { | 1503 | { |
1487 | RINOK(SendMessageError_with_LastError("Cannot seek to begin of file", fullProcessedPath)); | 1504 | RINOK(SendMessageError_with_LastError("Cannot seek to begin of file", fullProcessedPath)) |
1488 | } | 1505 | } |
1489 | } // PreAllocateOutFile | 1506 | } // PreAllocateOutFile |
1490 | 1507 | ||
@@ -1501,7 +1518,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1501 | 1518 | ||
1502 | if (_isSplit) | 1519 | if (_isSplit) |
1503 | { | 1520 | { |
1504 | RINOK(_outFileStreamSpec->Seek((Int64)_position, STREAM_SEEK_SET, NULL)); | 1521 | RINOK(outFileStream_Loc->Seek((Int64)_position, STREAM_SEEK_SET, NULL)) |
1505 | } | 1522 | } |
1506 | outStreamLoc = outFileStream_Loc; | 1523 | outStreamLoc = outFileStream_Loc; |
1507 | } // if not reprase | 1524 | } // if not reprase |
@@ -1516,7 +1533,7 @@ HRESULT CArchiveExtractCallback::GetExtractStream(CMyComPtr<ISequentialOutStream | |||
1516 | 1533 | ||
1517 | HRESULT CArchiveExtractCallback::GetItem(UInt32 index) | 1534 | HRESULT CArchiveExtractCallback::GetItem(UInt32 index) |
1518 | { | 1535 | { |
1519 | #ifndef _SFX | 1536 | #ifndef Z7_SFX |
1520 | _item._use_baseParentFolder_mode = _use_baseParentFolder_mode; | 1537 | _item._use_baseParentFolder_mode = _use_baseParentFolder_mode; |
1521 | if (_use_baseParentFolder_mode) | 1538 | if (_use_baseParentFolder_mode) |
1522 | { | 1539 | { |
@@ -1525,7 +1542,7 @@ HRESULT CArchiveExtractCallback::GetItem(UInt32 index) | |||
1525 | _pathMode == NExtract::NPathMode::kAbsPaths) | 1542 | _pathMode == NExtract::NPathMode::kAbsPaths) |
1526 | _item._baseParentFolder = -1; | 1543 | _item._baseParentFolder = -1; |
1527 | } | 1544 | } |
1528 | #endif // _SFX | 1545 | #endif // Z7_SFX |
1529 | 1546 | ||
1530 | #ifdef SUPPORT_ALT_STREAMS | 1547 | #ifdef SUPPORT_ALT_STREAMS |
1531 | _item.WriteToAltStreamIfColon = _ntOptions.WriteToAltStreamIfColon; | 1548 | _item.WriteToAltStreamIfColon = _ntOptions.WriteToAltStreamIfColon; |
@@ -1535,13 +1552,13 @@ HRESULT CArchiveExtractCallback::GetItem(UInt32 index) | |||
1535 | } | 1552 | } |
1536 | 1553 | ||
1537 | 1554 | ||
1538 | STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode) | 1555 | Z7_COM7F_IMF(CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)) |
1539 | { | 1556 | { |
1540 | COM_TRY_BEGIN | 1557 | COM_TRY_BEGIN |
1541 | 1558 | ||
1542 | *outStream = NULL; | 1559 | *outStream = NULL; |
1543 | 1560 | ||
1544 | #ifndef _SFX | 1561 | #ifndef Z7_SFX |
1545 | if (_hashStream) | 1562 | if (_hashStream) |
1546 | _hashStreamSpec->ReleaseStream(); | 1563 | _hashStreamSpec->ReleaseStream(); |
1547 | _hashStreamWasUsed = false; | 1564 | _hashStreamWasUsed = false; |
@@ -1555,8 +1572,8 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1555 | _isSplit = false; | 1572 | _isSplit = false; |
1556 | 1573 | ||
1557 | _curSize = 0; | 1574 | _curSize = 0; |
1558 | _curSizeDefined = false; | 1575 | _curSize_Defined = false; |
1559 | _fileLengthWasSet = false; | 1576 | _fileLength_WasSet = false; |
1560 | _fileLength_that_WasSet = 0; | 1577 | _fileLength_that_WasSet = 0; |
1561 | _index = index; | 1578 | _index = index; |
1562 | 1579 | ||
@@ -1574,7 +1591,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1574 | _itemFailure = false; | 1591 | _itemFailure = false; |
1575 | 1592 | ||
1576 | #ifdef SUPPORT_LINKS | 1593 | #ifdef SUPPORT_LINKS |
1577 | // _CopyFile_Path.Empty(); | 1594 | // _copyFile_Path.Empty(); |
1578 | _link.Clear(); | 1595 | _link.Clear(); |
1579 | #endif | 1596 | #endif |
1580 | 1597 | ||
@@ -1590,16 +1607,16 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1590 | else | 1607 | else |
1591 | _extractMode = true; | 1608 | _extractMode = true; |
1592 | break; | 1609 | break; |
1593 | }; | 1610 | } |
1594 | 1611 | ||
1595 | 1612 | ||
1596 | IInArchive *archive = _arc->Archive; | 1613 | IInArchive *archive = _arc->Archive; |
1597 | 1614 | ||
1598 | RINOK(GetItem(index)); | 1615 | RINOK(GetItem(index)) |
1599 | 1616 | ||
1600 | { | 1617 | { |
1601 | NCOM::CPropVariant prop; | 1618 | NCOM::CPropVariant prop; |
1602 | RINOK(archive->GetProperty(index, kpidPosition, &prop)); | 1619 | RINOK(archive->GetProperty(index, kpidPosition, &prop)) |
1603 | if (prop.vt != VT_EMPTY) | 1620 | if (prop.vt != VT_EMPTY) |
1604 | { | 1621 | { |
1605 | if (prop.vt != VT_UI8) | 1622 | if (prop.vt != VT_UI8) |
@@ -1610,13 +1627,13 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1610 | } | 1627 | } |
1611 | 1628 | ||
1612 | #ifdef SUPPORT_LINKS | 1629 | #ifdef SUPPORT_LINKS |
1613 | RINOK(ReadLink()); | 1630 | RINOK(ReadLink()) |
1614 | #endif // SUPPORT_LINKS | 1631 | #endif // SUPPORT_LINKS |
1615 | 1632 | ||
1616 | 1633 | ||
1617 | RINOK(Archive_GetItemBoolProp(archive, index, kpidEncrypted, _encrypted)); | 1634 | RINOK(Archive_GetItemBoolProp(archive, index, kpidEncrypted, _encrypted)) |
1618 | 1635 | ||
1619 | RINOK(GetUnpackSize()); | 1636 | RINOK(GetUnpackSize()) |
1620 | 1637 | ||
1621 | #ifdef SUPPORT_ALT_STREAMS | 1638 | #ifdef SUPPORT_ALT_STREAMS |
1622 | if (!_ntOptions.AltStreams.Val && _item.IsAltStream) | 1639 | if (!_ntOptions.AltStreams.Val && _item.IsAltStream) |
@@ -1632,7 +1649,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1632 | return S_OK; | 1649 | return S_OK; |
1633 | } | 1650 | } |
1634 | 1651 | ||
1635 | #ifndef _SFX | 1652 | #ifndef Z7_SFX |
1636 | if (_use_baseParentFolder_mode) | 1653 | if (_use_baseParentFolder_mode) |
1637 | { | 1654 | { |
1638 | if (!pathParts.IsEmpty()) | 1655 | if (!pathParts.IsEmpty()) |
@@ -1651,7 +1668,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1651 | } | 1668 | } |
1652 | } | 1669 | } |
1653 | else | 1670 | else |
1654 | #endif // _SFX | 1671 | #endif // Z7_SFX |
1655 | { | 1672 | { |
1656 | if (pathParts.IsEmpty()) | 1673 | if (pathParts.IsEmpty()) |
1657 | { | 1674 | { |
@@ -1734,12 +1751,8 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1734 | numRemovePathParts = pathParts.Size() - 1; | 1751 | numRemovePathParts = pathParts.Size() - 1; |
1735 | break; | 1752 | break; |
1736 | } | 1753 | } |
1737 | /* | ||
1738 | case NExtract::NPathMode::kFullPaths: | ||
1739 | case NExtract::NPathMode::kAbsPaths: | 1754 | case NExtract::NPathMode::kAbsPaths: |
1740 | break; | 1755 | // default: |
1741 | */ | ||
1742 | default: | ||
1743 | break; | 1756 | break; |
1744 | } | 1757 | } |
1745 | 1758 | ||
@@ -1747,7 +1760,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1747 | } | 1760 | } |
1748 | 1761 | ||
1749 | 1762 | ||
1750 | #ifndef _SFX | 1763 | #ifndef Z7_SFX |
1751 | 1764 | ||
1752 | if (ExtractToStreamCallback) | 1765 | if (ExtractToStreamCallback) |
1753 | { | 1766 | { |
@@ -1772,7 +1785,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1772 | return ExtractToStreamCallback->GetStream7(name, BoolToInt(_item.IsDir), outStream, askExtractMode, GetProp); | 1785 | return ExtractToStreamCallback->GetStream7(name, BoolToInt(_item.IsDir), outStream, askExtractMode, GetProp); |
1773 | } | 1786 | } |
1774 | 1787 | ||
1775 | #endif // _SFX | 1788 | #endif // Z7_SFX |
1776 | 1789 | ||
1777 | 1790 | ||
1778 | CMyComPtr<ISequentialOutStream> outStreamLoc; | 1791 | CMyComPtr<ISequentialOutStream> outStreamLoc; |
@@ -1784,13 +1797,13 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1784 | else | 1797 | else |
1785 | { | 1798 | { |
1786 | bool needExit = true; | 1799 | bool needExit = true; |
1787 | RINOK(GetExtractStream(outStreamLoc, needExit)); | 1800 | RINOK(GetExtractStream(outStreamLoc, needExit)) |
1788 | if (needExit) | 1801 | if (needExit) |
1789 | return S_OK; | 1802 | return S_OK; |
1790 | } | 1803 | } |
1791 | } | 1804 | } |
1792 | 1805 | ||
1793 | #ifndef _SFX | 1806 | #ifndef Z7_SFX |
1794 | if (_hashStream) | 1807 | if (_hashStream) |
1795 | { | 1808 | { |
1796 | if (askExtractMode == NArchive::NExtract::NAskMode::kExtract || | 1809 | if (askExtractMode == NArchive::NExtract::NAskMode::kExtract || |
@@ -1802,13 +1815,13 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1802 | _hashStreamWasUsed = true; | 1815 | _hashStreamWasUsed = true; |
1803 | } | 1816 | } |
1804 | } | 1817 | } |
1805 | #endif // _SFX | 1818 | #endif // Z7_SFX |
1806 | 1819 | ||
1807 | if (outStreamLoc) | 1820 | if (outStreamLoc) |
1808 | { | 1821 | { |
1809 | /* | 1822 | /* |
1810 | #ifdef SUPPORT_LINKS | 1823 | #ifdef SUPPORT_LINKS |
1811 | if (!_CopyFile_Path.IsEmpty()) | 1824 | if (!_copyFile_Path.IsEmpty()) |
1812 | { | 1825 | { |
1813 | RINOK(PrepareOperation(askExtractMode)); | 1826 | RINOK(PrepareOperation(askExtractMode)); |
1814 | RINOK(MyCopyFile(outStreamLoc)); | 1827 | RINOK(MyCopyFile(outStreamLoc)); |
@@ -1836,11 +1849,11 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
1836 | 1849 | ||
1837 | 1850 | ||
1838 | 1851 | ||
1839 | STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode) | 1852 | Z7_COM7F_IMF(CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)) |
1840 | { | 1853 | { |
1841 | COM_TRY_BEGIN | 1854 | COM_TRY_BEGIN |
1842 | 1855 | ||
1843 | #ifndef _SFX | 1856 | #ifndef Z7_SFX |
1844 | if (ExtractToStreamCallback) | 1857 | if (ExtractToStreamCallback) |
1845 | return ExtractToStreamCallback->PrepareOperation7(askExtractMode); | 1858 | return ExtractToStreamCallback->PrepareOperation7(askExtractMode); |
1846 | #endif | 1859 | #endif |
@@ -1855,10 +1868,10 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode) | |||
1855 | else | 1868 | else |
1856 | _extractMode = true; | 1869 | _extractMode = true; |
1857 | break; | 1870 | break; |
1858 | }; | 1871 | } |
1859 | 1872 | ||
1860 | return _extractCallback2->PrepareOperation(_item.Path, BoolToInt(_item.IsDir), | 1873 | return _extractCallback2->PrepareOperation(_item.Path, BoolToInt(_item.IsDir), |
1861 | askExtractMode, _isSplit ? &_position: 0); | 1874 | askExtractMode, _isSplit ? &_position: NULL); |
1862 | 1875 | ||
1863 | COM_TRY_END | 1876 | COM_TRY_END |
1864 | } | 1877 | } |
@@ -1875,28 +1888,28 @@ HRESULT CArchiveExtractCallback::CloseFile() | |||
1875 | HRESULT hres = S_OK; | 1888 | HRESULT hres = S_OK; |
1876 | 1889 | ||
1877 | const UInt64 processedSize = _outFileStreamSpec->ProcessedSize; | 1890 | const UInt64 processedSize = _outFileStreamSpec->ProcessedSize; |
1878 | if (_fileLengthWasSet && _fileLength_that_WasSet > processedSize) | 1891 | if (_fileLength_WasSet && _fileLength_that_WasSet > processedSize) |
1879 | { | 1892 | { |
1880 | bool res = _outFileStreamSpec->File.SetLength(processedSize); | 1893 | const bool res = _outFileStreamSpec->File.SetLength(processedSize); |
1881 | _fileLengthWasSet = res; | 1894 | _fileLength_WasSet = res; |
1882 | if (!res) | 1895 | if (!res) |
1883 | { | 1896 | { |
1884 | HRESULT hres2 = SendMessageError_with_LastError(kCantSetFileLen, us2fs(_item.Path)); | 1897 | const HRESULT hres2 = SendMessageError_with_LastError(kCantSetFileLen, us2fs(_item.Path)); |
1885 | if (hres == S_OK) | 1898 | if (hres == S_OK) |
1886 | hres = hres2; | 1899 | hres = hres2; |
1887 | } | 1900 | } |
1888 | } | 1901 | } |
1889 | 1902 | ||
1890 | _curSize = processedSize; | 1903 | _curSize = processedSize; |
1891 | _curSizeDefined = true; | 1904 | _curSize_Defined = true; |
1892 | 1905 | ||
1893 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(_SFX) | 1906 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX) |
1894 | if (ZoneBuf.Size() != 0 | 1907 | if (ZoneBuf.Size() != 0 |
1895 | && !_item.IsAltStream) | 1908 | && !_item.IsAltStream) |
1896 | { | 1909 | { |
1897 | // if (NFind::DoesFileExist_Raw(tempFilePath)) | 1910 | // if (NFind::DoesFileExist_Raw(tempFilePath)) |
1898 | if (ZoneMode != NExtract::NZoneIdMode::kOffice || | 1911 | if (ZoneMode != NExtract::NZoneIdMode::kOffice || |
1899 | FindExt2(kOfficeExtensions, _diskFilePath)) | 1912 | FindExt2(kOfficeExtensions, fs2us(_diskFilePath))) |
1900 | { | 1913 | { |
1901 | // we must write zone file before setting of timestamps | 1914 | // we must write zone file before setting of timestamps |
1902 | const FString path = _diskFilePath + k_ZoneId_StreamName; | 1915 | const FString path = _diskFilePath + k_ZoneId_StreamName; |
@@ -1920,7 +1933,7 @@ HRESULT CArchiveExtractCallback::CloseFile() | |||
1920 | t.MTime_Defined ? &t.MTime : NULL); | 1933 | t.MTime_Defined ? &t.MTime : NULL); |
1921 | // #endif | 1934 | // #endif |
1922 | 1935 | ||
1923 | RINOK(_outFileStreamSpec->Close()); | 1936 | RINOK(_outFileStreamSpec->Close()) |
1924 | _outFileStream.Release(); | 1937 | _outFileStream.Release(); |
1925 | return hres; | 1938 | return hres; |
1926 | } | 1939 | } |
@@ -1964,7 +1977,7 @@ HRESULT CArchiveExtractCallback::SetFromLinkPath( | |||
1964 | { | 1977 | { |
1965 | if (!NName::GetFullPath(_dirPathPrefix_Full, us2fs(relatPath), existPath)) | 1978 | if (!NName::GetFullPath(_dirPathPrefix_Full, us2fs(relatPath), existPath)) |
1966 | { | 1979 | { |
1967 | RINOK(SendMessageError("Incorrect path", us2fs(relatPath))); | 1980 | RINOK(SendMessageError("Incorrect path", us2fs(relatPath))) |
1968 | } | 1981 | } |
1969 | } | 1982 | } |
1970 | else | 1983 | else |
@@ -1982,8 +1995,8 @@ HRESULT CArchiveExtractCallback::SetFromLinkPath( | |||
1982 | { | 1995 | { |
1983 | if (!MyCreateHardLink(fullProcessedPath, existPath)) | 1996 | if (!MyCreateHardLink(fullProcessedPath, existPath)) |
1984 | { | 1997 | { |
1985 | HRESULT errorCode = GetLastError_noZero_HRESULT(); | 1998 | const HRESULT errorCode = GetLastError_noZero_HRESULT(); |
1986 | RINOK(SendMessageError2(errorCode, kCantCreateHardLink, fullProcessedPath, existPath)); | 1999 | RINOK(SendMessageError2(errorCode, kCantCreateHardLink, fullProcessedPath, existPath)) |
1987 | } | 2000 | } |
1988 | linkWasSet = true; | 2001 | linkWasSet = true; |
1989 | return S_OK; | 2002 | return S_OK; |
@@ -1998,8 +2011,8 @@ HRESULT CArchiveExtractCallback::SetFromLinkPath( | |||
1998 | } | 2011 | } |
1999 | else | 2012 | else |
2000 | { | 2013 | { |
2001 | if (_curSizeDefined && _curSize == fi.Size) | 2014 | if (_curSize_Defined && _curSize == fi.Size) |
2002 | _CopyFile_Path = existPath; | 2015 | _copyFile_Path = existPath; |
2003 | else | 2016 | else |
2004 | { | 2017 | { |
2005 | RINOK(SendMessageError2("File size collision for file copying", existPath, fullProcessedPath)); | 2018 | RINOK(SendMessageError2("File size collision for file copying", existPath, fullProcessedPath)); |
@@ -2060,12 +2073,12 @@ HRESULT CArchiveExtractCallback::SetFromLinkPath( | |||
2060 | CReparseAttr attr; | 2073 | CReparseAttr attr; |
2061 | if (!attr.Parse(data, data.Size())) | 2074 | if (!attr.Parse(data, data.Size())) |
2062 | { | 2075 | { |
2063 | RINOK(SendMessageError("Internal error for symbolic link file", us2fs(_item.Path))); | 2076 | RINOK(SendMessageError("Internal error for symbolic link file", us2fs(_item.Path))) |
2064 | return S_OK; | 2077 | return S_OK; |
2065 | } | 2078 | } |
2066 | if (!NFile::NIO::SetReparseData(fullProcessedPath, _item.IsDir, data, (DWORD)data.Size())) | 2079 | if (!NFile::NIO::SetReparseData(fullProcessedPath, _item.IsDir, data, (DWORD)data.Size())) |
2067 | { | 2080 | { |
2068 | RINOK(SendMessageError_with_LastError(kCantCreateSymLink, fullProcessedPath)); | 2081 | RINOK(SendMessageError_with_LastError(kCantCreateSymLink, fullProcessedPath)) |
2069 | return S_OK; | 2082 | return S_OK; |
2070 | } | 2083 | } |
2071 | linkWasSet = true; | 2084 | linkWasSet = true; |
@@ -2077,7 +2090,7 @@ HRESULT CArchiveExtractCallback::SetFromLinkPath( | |||
2077 | 2090 | ||
2078 | if (!NFile::NIO::SetSymLink(fullProcessedPath, existPath)) | 2091 | if (!NFile::NIO::SetSymLink(fullProcessedPath, existPath)) |
2079 | { | 2092 | { |
2080 | RINOK(SendMessageError_with_LastError(kCantCreateSymLink, fullProcessedPath)); | 2093 | RINOK(SendMessageError_with_LastError(kCantCreateSymLink, fullProcessedPath)) |
2081 | return S_OK; | 2094 | return S_OK; |
2082 | } | 2095 | } |
2083 | linkWasSet = true; | 2096 | linkWasSet = true; |
@@ -2110,7 +2123,7 @@ bool CLinkInfo::Parse(const Byte *data, size_t dataSize, bool isLinuxData) | |||
2110 | // if windows link was created, then we also must use linux separator | 2123 | // if windows link was created, then we also must use linux separator |
2111 | if (u.IsEmpty()) | 2124 | if (u.IsEmpty()) |
2112 | return false; | 2125 | return false; |
2113 | wchar_t c = u[0]; | 2126 | const wchar_t c = u[0]; |
2114 | isRelative = !IS_PATH_SEPAR(c); | 2127 | isRelative = !IS_PATH_SEPAR(c); |
2115 | return true; | 2128 | return true; |
2116 | } | 2129 | } |
@@ -2157,7 +2170,7 @@ HRESULT CArchiveExtractCallback::CloseReparseAndFile() | |||
2157 | { | 2170 | { |
2158 | repraseMode = true; | 2171 | repraseMode = true; |
2159 | reparseSize = _bufPtrSeqOutStream_Spec->GetPos(); | 2172 | reparseSize = _bufPtrSeqOutStream_Spec->GetPos(); |
2160 | if (_curSizeDefined && reparseSize == _outMemBuf.Size()) | 2173 | if (_curSize_Defined && reparseSize == _outMemBuf.Size()) |
2161 | { | 2174 | { |
2162 | /* | 2175 | /* |
2163 | CReparseAttr reparse; | 2176 | CReparseAttr reparse; |
@@ -2181,7 +2194,7 @@ HRESULT CArchiveExtractCallback::CloseReparseAndFile() | |||
2181 | } | 2194 | } |
2182 | if (!needSetReparse && _outFileStream) | 2195 | if (!needSetReparse && _outFileStream) |
2183 | { | 2196 | { |
2184 | HRESULT res2 = WriteStream(_outFileStream, _outMemBuf, reparseSize); | 2197 | const HRESULT res2 = WriteStream(_outFileStream, _outMemBuf, reparseSize); |
2185 | if (res == S_OK) | 2198 | if (res == S_OK) |
2186 | res = res2; | 2199 | res = res2; |
2187 | } | 2200 | } |
@@ -2191,18 +2204,18 @@ HRESULT CArchiveExtractCallback::CloseReparseAndFile() | |||
2191 | #endif // SUPPORT_LINKS | 2204 | #endif // SUPPORT_LINKS |
2192 | 2205 | ||
2193 | 2206 | ||
2194 | HRESULT res2 = CloseFile(); | 2207 | const HRESULT res2 = CloseFile(); |
2195 | 2208 | ||
2196 | if (res == S_OK) | 2209 | if (res == S_OK) |
2197 | res = res2; | 2210 | res = res2; |
2198 | 2211 | ||
2199 | RINOK(res); | 2212 | RINOK(res) |
2200 | 2213 | ||
2201 | #ifdef SUPPORT_LINKS | 2214 | #ifdef SUPPORT_LINKS |
2202 | if (repraseMode) | 2215 | if (repraseMode) |
2203 | { | 2216 | { |
2204 | _curSize = reparseSize; | 2217 | _curSize = reparseSize; |
2205 | _curSizeDefined = true; | 2218 | _curSize_Defined = true; |
2206 | 2219 | ||
2207 | #ifdef SUPPORT_LINKS | 2220 | #ifdef SUPPORT_LINKS |
2208 | if (needSetReparse) | 2221 | if (needSetReparse) |
@@ -2211,19 +2224,19 @@ HRESULT CArchiveExtractCallback::CloseReparseAndFile() | |||
2211 | // in Windows : we can create symbolic link even without file deleting | 2224 | // in Windows : we can create symbolic link even without file deleting |
2212 | if (!DeleteFileAlways(_diskFilePath)) | 2225 | if (!DeleteFileAlways(_diskFilePath)) |
2213 | { | 2226 | { |
2214 | RINOK(SendMessageError_with_LastError("can't delete file", _diskFilePath)); | 2227 | RINOK(SendMessageError_with_LastError("can't delete file", _diskFilePath)) |
2215 | } | 2228 | } |
2216 | { | 2229 | { |
2217 | /* | 2230 | /* |
2218 | // for DEBUG ONLY: we can extract sym links as WSL links | 2231 | // for DEBUG ONLY: we can extract sym links as WSL links |
2219 | // to elimanate (non-admin) errors for sym links. | 2232 | // to eliminate (non-admin) errors for sym links. |
2220 | #ifdef _WIN32 | 2233 | #ifdef _WIN32 |
2221 | if (!linkInfo.isHardLink && !linkInfo.isJunction) | 2234 | if (!linkInfo.isHardLink && !linkInfo.isJunction) |
2222 | linkInfo.isWSL = true; | 2235 | linkInfo.isWSL = true; |
2223 | #endif | 2236 | #endif |
2224 | */ | 2237 | */ |
2225 | bool linkWasSet = false; | 2238 | bool linkWasSet = false; |
2226 | RINOK(SetFromLinkPath(_diskFilePath, linkInfo, linkWasSet)); | 2239 | RINOK(SetFromLinkPath(_diskFilePath, linkInfo, linkWasSet)) |
2227 | if (linkWasSet) | 2240 | if (linkWasSet) |
2228 | _isSymLinkCreated = linkInfo.IsSymLink(); | 2241 | _isSymLinkCreated = linkInfo.IsSymLink(); |
2229 | else | 2242 | else |
@@ -2282,13 +2295,13 @@ void CArchiveExtractCallback::SetAttrib() | |||
2282 | } | 2295 | } |
2283 | 2296 | ||
2284 | 2297 | ||
2285 | STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes) | 2298 | Z7_COM7F_IMF(CArchiveExtractCallback::SetOperationResult(Int32 opRes)) |
2286 | { | 2299 | { |
2287 | COM_TRY_BEGIN | 2300 | COM_TRY_BEGIN |
2288 | 2301 | ||
2289 | // printf("\nCArchiveExtractCallback::SetOperationResult: %d %s\n", opRes, GetAnsiString(_diskFilePath)); | 2302 | // printf("\nCArchiveExtractCallback::SetOperationResult: %d %s\n", opRes, GetAnsiString(_diskFilePath)); |
2290 | 2303 | ||
2291 | #ifndef _SFX | 2304 | #ifndef Z7_SFX |
2292 | if (ExtractToStreamCallback) | 2305 | if (ExtractToStreamCallback) |
2293 | { | 2306 | { |
2294 | GetUnpackSize(); | 2307 | GetUnpackSize(); |
@@ -2296,7 +2309,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes) | |||
2296 | } | 2309 | } |
2297 | #endif | 2310 | #endif |
2298 | 2311 | ||
2299 | #ifndef _SFX | 2312 | #ifndef Z7_SFX |
2300 | 2313 | ||
2301 | if (_hashStreamWasUsed) | 2314 | if (_hashStreamWasUsed) |
2302 | { | 2315 | { |
@@ -2308,16 +2321,16 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes) | |||
2308 | #endif | 2321 | #endif |
2309 | , _item.Path); | 2322 | , _item.Path); |
2310 | _curSize = _hashStreamSpec->GetSize(); | 2323 | _curSize = _hashStreamSpec->GetSize(); |
2311 | _curSizeDefined = true; | 2324 | _curSize_Defined = true; |
2312 | _hashStreamSpec->ReleaseStream(); | 2325 | _hashStreamSpec->ReleaseStream(); |
2313 | _hashStreamWasUsed = false; | 2326 | _hashStreamWasUsed = false; |
2314 | } | 2327 | } |
2315 | 2328 | ||
2316 | #endif // _SFX | 2329 | #endif // Z7_SFX |
2317 | 2330 | ||
2318 | RINOK(CloseReparseAndFile()); | 2331 | RINOK(CloseReparseAndFile()) |
2319 | 2332 | ||
2320 | #ifdef _USE_SECURITY_CODE | 2333 | #ifdef Z7_USE_SECURITY_CODE |
2321 | if (!_stdOutMode && _extractMode && _ntOptions.NtSecurity.Val && _arc->GetRawProps) | 2334 | if (!_stdOutMode && _extractMode && _ntOptions.NtSecurity.Val && _arc->GetRawProps) |
2322 | { | 2335 | { |
2323 | const void *data; | 2336 | const void *data; |
@@ -2337,12 +2350,12 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes) | |||
2337 | } | 2350 | } |
2338 | } | 2351 | } |
2339 | } | 2352 | } |
2340 | #endif // _USE_SECURITY_CODE | 2353 | #endif // Z7_USE_SECURITY_CODE |
2341 | 2354 | ||
2342 | if (!_curSizeDefined) | 2355 | if (!_curSize_Defined) |
2343 | GetUnpackSize(); | 2356 | GetUnpackSize(); |
2344 | 2357 | ||
2345 | if (_curSizeDefined) | 2358 | if (_curSize_Defined) |
2346 | { | 2359 | { |
2347 | #ifdef SUPPORT_ALT_STREAMS | 2360 | #ifdef SUPPORT_ALT_STREAMS |
2348 | if (_item.IsAltStream) | 2361 | if (_item.IsAltStream) |
@@ -2364,7 +2377,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes) | |||
2364 | if (_needSetAttrib) | 2377 | if (_needSetAttrib) |
2365 | SetAttrib(); | 2378 | SetAttrib(); |
2366 | 2379 | ||
2367 | RINOK(_extractCallback2->SetOperationResult(opRes, BoolToInt(_encrypted))); | 2380 | RINOK(_extractCallback2->SetOperationResult(opRes, BoolToInt(_encrypted))) |
2368 | 2381 | ||
2369 | return S_OK; | 2382 | return S_OK; |
2370 | 2383 | ||
@@ -2373,7 +2386,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes) | |||
2373 | 2386 | ||
2374 | 2387 | ||
2375 | 2388 | ||
2376 | STDMETHODIMP CArchiveExtractCallback::ReportExtractResult(UInt32 indexType, UInt32 index, Int32 opRes) | 2389 | Z7_COM7F_IMF(CArchiveExtractCallback::ReportExtractResult(UInt32 indexType, UInt32 index, Int32 opRes)) |
2377 | { | 2390 | { |
2378 | if (_folderArchiveExtractCallback2) | 2391 | if (_folderArchiveExtractCallback2) |
2379 | { | 2392 | { |
@@ -2383,9 +2396,9 @@ STDMETHODIMP CArchiveExtractCallback::ReportExtractResult(UInt32 indexType, UInt | |||
2383 | if (indexType == NArchive::NEventIndexType::kInArcIndex && index != (UInt32)(Int32)-1) | 2396 | if (indexType == NArchive::NEventIndexType::kInArcIndex && index != (UInt32)(Int32)-1) |
2384 | { | 2397 | { |
2385 | CReadArcItem item; | 2398 | CReadArcItem item; |
2386 | RINOK(_arc->GetItem(index, item)); | 2399 | RINOK(_arc->GetItem(index, item)) |
2387 | s = item.Path; | 2400 | s = item.Path; |
2388 | RINOK(Archive_GetItemBoolProp(_arc->Archive, index, kpidEncrypted, isEncrypted)); | 2401 | RINOK(Archive_GetItemBoolProp(_arc->Archive, index, kpidEncrypted, isEncrypted)) |
2389 | } | 2402 | } |
2390 | else | 2403 | else |
2391 | { | 2404 | { |
@@ -2401,13 +2414,13 @@ STDMETHODIMP CArchiveExtractCallback::ReportExtractResult(UInt32 indexType, UInt | |||
2401 | } | 2414 | } |
2402 | 2415 | ||
2403 | 2416 | ||
2404 | STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password) | 2417 | Z7_COM7F_IMF(CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)) |
2405 | { | 2418 | { |
2406 | COM_TRY_BEGIN | 2419 | COM_TRY_BEGIN |
2407 | if (!_cryptoGetTextPassword) | 2420 | if (!_cryptoGetTextPassword) |
2408 | { | 2421 | { |
2409 | RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword, | 2422 | RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword, |
2410 | &_cryptoGetTextPassword)); | 2423 | &_cryptoGetTextPassword)) |
2411 | } | 2424 | } |
2412 | return _cryptoGetTextPassword->CryptoGetTextPassword(password); | 2425 | return _cryptoGetTextPassword->CryptoGetTextPassword(password); |
2413 | COM_TRY_END | 2426 | COM_TRY_END |
@@ -2435,13 +2448,13 @@ FString CArchiveExtractCallback::Hash_GetFullFilePath() | |||
2435 | } | 2448 | } |
2436 | 2449 | ||
2437 | 2450 | ||
2438 | STDMETHODIMP CArchiveExtractCallback::GetDiskProperty(UInt32 index, PROPID propID, PROPVARIANT *value) | 2451 | Z7_COM7F_IMF(CArchiveExtractCallback::GetDiskProperty(UInt32 index, PROPID propID, PROPVARIANT *value)) |
2439 | { | 2452 | { |
2440 | COM_TRY_BEGIN | 2453 | COM_TRY_BEGIN |
2441 | NCOM::CPropVariant prop; | 2454 | NCOM::CPropVariant prop; |
2442 | if (propID == kpidSize) | 2455 | if (propID == kpidSize) |
2443 | { | 2456 | { |
2444 | RINOK(GetItem(index)); | 2457 | RINOK(GetItem(index)) |
2445 | const FString fullProcessedPath = Hash_GetFullFilePath(); | 2458 | const FString fullProcessedPath = Hash_GetFullFilePath(); |
2446 | NFile::NFind::CFileInfo fi; | 2459 | NFile::NFind::CFileInfo fi; |
2447 | if (fi.Find_FollowLink(fullProcessedPath)) | 2460 | if (fi.Find_FollowLink(fullProcessedPath)) |
@@ -2454,7 +2467,7 @@ STDMETHODIMP CArchiveExtractCallback::GetDiskProperty(UInt32 index, PROPID propI | |||
2454 | } | 2467 | } |
2455 | 2468 | ||
2456 | 2469 | ||
2457 | STDMETHODIMP CArchiveExtractCallback::GetStream2(UInt32 index, ISequentialInStream **inStream, UInt32 mode) | 2470 | Z7_COM7F_IMF(CArchiveExtractCallback::GetStream2(UInt32 index, ISequentialInStream **inStream, UInt32 mode)) |
2458 | { | 2471 | { |
2459 | COM_TRY_BEGIN | 2472 | COM_TRY_BEGIN |
2460 | *inStream = NULL; | 2473 | *inStream = NULL; |
@@ -2462,7 +2475,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream2(UInt32 index, ISequentialInStre | |||
2462 | if (mode != NUpdateNotifyOp::kHashRead) | 2475 | if (mode != NUpdateNotifyOp::kHashRead) |
2463 | return E_FAIL; | 2476 | return E_FAIL; |
2464 | 2477 | ||
2465 | RINOK(GetItem(index)); | 2478 | RINOK(GetItem(index)) |
2466 | const FString fullProcessedPath = Hash_GetFullFilePath(); | 2479 | const FString fullProcessedPath = Hash_GetFullFilePath(); |
2467 | 2480 | ||
2468 | CInFileStream *inStreamSpec = new CInFileStream; | 2481 | CInFileStream *inStreamSpec = new CInFileStream; |
@@ -2470,7 +2483,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream2(UInt32 index, ISequentialInStre | |||
2470 | inStreamSpec->Set_PreserveATime(_ntOptions.PreserveATime); | 2483 | inStreamSpec->Set_PreserveATime(_ntOptions.PreserveATime); |
2471 | if (!inStreamSpec->OpenShared(fullProcessedPath, _ntOptions.OpenShareForWrite)) | 2484 | if (!inStreamSpec->OpenShared(fullProcessedPath, _ntOptions.OpenShareForWrite)) |
2472 | { | 2485 | { |
2473 | RINOK(SendMessageError_with_LastError(kCantOpenInFile, fullProcessedPath)); | 2486 | RINOK(SendMessageError_with_LastError(kCantOpenInFile, fullProcessedPath)) |
2474 | return S_OK; | 2487 | return S_OK; |
2475 | } | 2488 | } |
2476 | *inStream = inStreamRef.Detach(); | 2489 | *inStream = inStreamRef.Detach(); |
@@ -2479,8 +2492,8 @@ STDMETHODIMP CArchiveExtractCallback::GetStream2(UInt32 index, ISequentialInStre | |||
2479 | } | 2492 | } |
2480 | 2493 | ||
2481 | 2494 | ||
2482 | STDMETHODIMP CArchiveExtractCallback::ReportOperation( | 2495 | Z7_COM7F_IMF(CArchiveExtractCallback::ReportOperation( |
2483 | UInt32 /* indexType */, UInt32 /* index */, UInt32 /* op */) | 2496 | UInt32 /* indexType */, UInt32 /* index */, UInt32 /* op */)) |
2484 | { | 2497 | { |
2485 | // COM_TRY_BEGIN | 2498 | // COM_TRY_BEGIN |
2486 | return S_OK; | 2499 | return S_OK; |
@@ -2571,7 +2584,7 @@ HRESULT CArchiveExtractCallback::SetDirsTimes() | |||
2571 | HRESULT CArchiveExtractCallback::CloseArc() | 2584 | HRESULT CArchiveExtractCallback::CloseArc() |
2572 | { | 2585 | { |
2573 | HRESULT res = CloseReparseAndFile(); | 2586 | HRESULT res = CloseReparseAndFile(); |
2574 | HRESULT res2 = SetDirsTimes(); | 2587 | const HRESULT res2 = SetDirsTimes(); |
2575 | if (res == S_OK) | 2588 | if (res == S_OK) |
2576 | res = res2; | 2589 | res = res2; |
2577 | _arc = NULL; | 2590 | _arc = NULL; |
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.h b/CPP/7zip/UI/Common/ArchiveExtractCallback.h index fe70bc9..5ed20f3 100644 --- a/CPP/7zip/UI/Common/ArchiveExtractCallback.h +++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // ArchiveExtractCallback.h | 1 | // ArchiveExtractCallback.h |
2 | 2 | ||
3 | #ifndef __ARCHIVE_EXTRACT_CALLBACK_H | 3 | #ifndef ZIP7_INC_ARCHIVE_EXTRACT_CALLBACK_H |
4 | #define __ARCHIVE_EXTRACT_CALLBACK_H | 4 | #define ZIP7_INC_ARCHIVE_EXTRACT_CALLBACK_H |
5 | 5 | ||
6 | #include "../../../Common/MyCom.h" | 6 | #include "../../../Common/MyCom.h" |
7 | #include "../../../Common/MyLinux.h" | 7 | #include "../../../Common/MyLinux.h" |
@@ -21,20 +21,18 @@ | |||
21 | 21 | ||
22 | #include "HashCalc.h" | 22 | #include "HashCalc.h" |
23 | 23 | ||
24 | #ifndef _SFX | 24 | #ifndef Z7_SFX |
25 | 25 | ||
26 | class COutStreamWithHash: | 26 | Z7_CLASS_IMP_NOQIB_1( |
27 | public ISequentialOutStream, | 27 | COutStreamWithHash |
28 | public CMyUnknownImp | 28 | , ISequentialOutStream |
29 | { | 29 | ) |
30 | CMyComPtr<ISequentialOutStream> _stream; | 30 | CMyComPtr<ISequentialOutStream> _stream; |
31 | UInt64 _size; | 31 | UInt64 _size; |
32 | bool _calculate; | 32 | bool _calculate; |
33 | public: | 33 | public: |
34 | IHashCalc *_hash; | 34 | IHashCalc *_hash; |
35 | 35 | ||
36 | MY_UNKNOWN_IMP | ||
37 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | ||
38 | void SetStream(ISequentialOutStream *stream) { _stream = stream; } | 36 | void SetStream(ISequentialOutStream *stream) { _stream = stream; } |
39 | void ReleaseStream() { _stream.Release(); } | 37 | void ReleaseStream() { _stream.Release(); } |
40 | void Init(bool calculate = true) | 38 | void Init(bool calculate = true) |
@@ -89,24 +87,21 @@ struct CExtractNtOptions | |||
89 | } | 87 | } |
90 | }; | 88 | }; |
91 | 89 | ||
92 | #ifndef _SFX | 90 | #ifndef Z7_SFX |
93 | 91 | ||
94 | class CGetProp: | 92 | Z7_CLASS_IMP_COM_1( |
95 | public IGetProp, | 93 | CGetProp |
96 | public CMyUnknownImp | 94 | , IGetProp |
97 | { | 95 | ) |
98 | public: | 96 | public: |
99 | const CArc *Arc; | ||
100 | UInt32 IndexInArc; | 97 | UInt32 IndexInArc; |
98 | const CArc *Arc; | ||
101 | // UString Name; // relative path | 99 | // UString Name; // relative path |
102 | |||
103 | MY_UNKNOWN_IMP1(IGetProp) | ||
104 | INTERFACE_IGetProp(;) | ||
105 | }; | 100 | }; |
106 | 101 | ||
107 | #endif | 102 | #endif |
108 | 103 | ||
109 | #ifndef _SFX | 104 | #ifndef Z7_SFX |
110 | #ifndef UNDER_CE | 105 | #ifndef UNDER_CE |
111 | 106 | ||
112 | #define SUPPORT_LINKS | 107 | #define SUPPORT_LINKS |
@@ -249,32 +244,75 @@ struct COwnerInfo | |||
249 | #endif | 244 | #endif |
250 | 245 | ||
251 | 246 | ||
252 | class CArchiveExtractCallback: | 247 | class CArchiveExtractCallback Z7_final: |
253 | public IArchiveExtractCallback, | 248 | public IArchiveExtractCallback, |
254 | public IArchiveExtractCallbackMessage, | 249 | public IArchiveExtractCallbackMessage2, |
255 | public ICryptoGetTextPassword, | 250 | public ICryptoGetTextPassword, |
256 | public ICompressProgressInfo, | 251 | public ICompressProgressInfo, |
257 | public IArchiveUpdateCallbackFile, | 252 | public IArchiveUpdateCallbackFile, |
258 | public IArchiveGetDiskProperty, | 253 | public IArchiveGetDiskProperty, |
259 | public CMyUnknownImp | 254 | public CMyUnknownImp |
260 | { | 255 | { |
256 | Z7_COM_UNKNOWN_IMP_5( | ||
257 | /* IArchiveExtractCallback, */ | ||
258 | IArchiveExtractCallbackMessage2, | ||
259 | ICryptoGetTextPassword, | ||
260 | ICompressProgressInfo, | ||
261 | IArchiveUpdateCallbackFile, | ||
262 | IArchiveGetDiskProperty) | ||
263 | |||
264 | Z7_IFACE_COM7_IMP(IProgress) | ||
265 | Z7_IFACE_COM7_IMP(IArchiveExtractCallback) | ||
266 | Z7_IFACE_COM7_IMP(IArchiveExtractCallbackMessage2) | ||
267 | Z7_IFACE_COM7_IMP(ICryptoGetTextPassword) | ||
268 | Z7_IFACE_COM7_IMP(ICompressProgressInfo) | ||
269 | Z7_IFACE_COM7_IMP(IArchiveUpdateCallbackFile) | ||
270 | Z7_IFACE_COM7_IMP(IArchiveGetDiskProperty) | ||
271 | |||
261 | const CArc *_arc; | 272 | const CArc *_arc; |
262 | CExtractNtOptions _ntOptions; | 273 | CExtractNtOptions _ntOptions; |
263 | 274 | ||
275 | bool _isSplit; | ||
276 | |||
277 | bool _extractMode; | ||
278 | |||
279 | bool Write_CTime; | ||
280 | bool Write_ATime; | ||
281 | bool Write_MTime; | ||
282 | bool _keepAndReplaceEmptyDirPrefixes; // replace them to "_"; | ||
283 | |||
284 | bool _encrypted; | ||
285 | |||
286 | // bool _is_SymLink_in_Data; | ||
287 | bool _is_SymLink_in_Data_Linux; // false = WIN32, true = LINUX | ||
288 | |||
289 | bool _needSetAttrib; | ||
290 | bool _isSymLinkCreated; | ||
291 | bool _itemFailure; | ||
292 | |||
293 | bool _curSize_Defined; | ||
294 | bool _fileLength_WasSet; | ||
295 | |||
296 | bool _removePartsForAltStreams; | ||
297 | |||
298 | bool _stdOutMode; | ||
299 | bool _testMode; | ||
300 | bool _multiArchives; | ||
301 | |||
302 | NExtract::NPathMode::EEnum _pathMode; | ||
303 | NExtract::NOverwriteMode::EEnum _overwriteMode; | ||
304 | |||
264 | const NWildcard::CCensorNode *_wildcardCensor; // we need wildcard for single pass mode (stdin) | 305 | const NWildcard::CCensorNode *_wildcardCensor; // we need wildcard for single pass mode (stdin) |
265 | CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2; | 306 | CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2; |
266 | CMyComPtr<ICompressProgressInfo> _compressProgress; | 307 | // CMyComPtr<ICompressProgressInfo> _compressProgress; |
267 | CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword; | 308 | // CMyComPtr<IArchiveExtractCallbackMessage2> _callbackMessage; |
268 | CMyComPtr<IArchiveExtractCallbackMessage> _callbackMessage; | ||
269 | CMyComPtr<IFolderArchiveExtractCallback2> _folderArchiveExtractCallback2; | 309 | CMyComPtr<IFolderArchiveExtractCallback2> _folderArchiveExtractCallback2; |
310 | CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword; | ||
270 | 311 | ||
271 | FString _dirPathPrefix; | 312 | FString _dirPathPrefix; |
272 | FString _dirPathPrefix_Full; | 313 | FString _dirPathPrefix_Full; |
273 | NExtract::NPathMode::EEnum _pathMode; | ||
274 | NExtract::NOverwriteMode::EEnum _overwriteMode; | ||
275 | bool _keepAndReplaceEmptyDirPrefixes; // replace them to "_"; | ||
276 | 314 | ||
277 | #ifndef _SFX | 315 | #ifndef Z7_SFX |
278 | 316 | ||
279 | CMyComPtr<IFolderExtractToStreamCallback> ExtractToStreamCallback; | 317 | CMyComPtr<IFolderExtractToStreamCallback> ExtractToStreamCallback; |
280 | CGetProp *GetProp_Spec; | 318 | CGetProp *GetProp_Spec; |
@@ -285,15 +323,6 @@ class CArchiveExtractCallback: | |||
285 | CReadArcItem _item; | 323 | CReadArcItem _item; |
286 | FString _diskFilePath; | 324 | FString _diskFilePath; |
287 | UInt64 _position; | 325 | UInt64 _position; |
288 | bool _isSplit; | ||
289 | |||
290 | bool _extractMode; | ||
291 | |||
292 | bool Write_CTime; | ||
293 | bool Write_ATime; | ||
294 | bool Write_MTime; | ||
295 | |||
296 | bool _encrypted; | ||
297 | 326 | ||
298 | struct CProcessedFileInfo | 327 | struct CProcessedFileInfo |
299 | { | 328 | { |
@@ -339,17 +368,8 @@ class CArchiveExtractCallback: | |||
339 | } | 368 | } |
340 | } _fi; | 369 | } _fi; |
341 | 370 | ||
342 | // bool _is_SymLink_in_Data; | ||
343 | bool _is_SymLink_in_Data_Linux; // false = WIN32, true = LINUX | ||
344 | |||
345 | bool _needSetAttrib; | ||
346 | bool _isSymLinkCreated; | ||
347 | bool _itemFailure; | ||
348 | |||
349 | UInt32 _index; | 371 | UInt32 _index; |
350 | UInt64 _curSize; | 372 | UInt64 _curSize; |
351 | bool _curSizeDefined; | ||
352 | bool _fileLengthWasSet; | ||
353 | UInt64 _fileLength_that_WasSet; | 373 | UInt64 _fileLength_that_WasSet; |
354 | 374 | ||
355 | COutFileStream *_outFileStreamSpec; | 375 | COutFileStream *_outFileStreamSpec; |
@@ -360,25 +380,17 @@ class CArchiveExtractCallback: | |||
360 | CMyComPtr<ISequentialOutStream> _bufPtrSeqOutStream; | 380 | CMyComPtr<ISequentialOutStream> _bufPtrSeqOutStream; |
361 | 381 | ||
362 | 382 | ||
363 | #ifndef _SFX | 383 | #ifndef Z7_SFX |
364 | 384 | ||
365 | COutStreamWithHash *_hashStreamSpec; | 385 | COutStreamWithHash *_hashStreamSpec; |
366 | CMyComPtr<ISequentialOutStream> _hashStream; | 386 | CMyComPtr<ISequentialOutStream> _hashStream; |
367 | bool _hashStreamWasUsed; | 387 | bool _hashStreamWasUsed; |
368 | 388 | ||
369 | #endif | ||
370 | |||
371 | bool _removePartsForAltStreams; | ||
372 | UStringVector _removePathParts; | ||
373 | |||
374 | #ifndef _SFX | ||
375 | bool _use_baseParentFolder_mode; | 389 | bool _use_baseParentFolder_mode; |
376 | UInt32 _baseParentFolder; | 390 | UInt32 _baseParentFolder; |
377 | #endif | 391 | #endif |
378 | 392 | ||
379 | bool _stdOutMode; | 393 | UStringVector _removePathParts; |
380 | bool _testMode; | ||
381 | bool _multiArchives; | ||
382 | 394 | ||
383 | CMyComPtr<ICompressProgressInfo> _localProgress; | 395 | CMyComPtr<ICompressProgressInfo> _localProgress; |
384 | UInt64 _packTotal; | 396 | UInt64 _packTotal; |
@@ -392,7 +404,7 @@ class CArchiveExtractCallback: | |||
392 | // CObjectVector<NWindows::NFile::NDir::CDelayedSymLink> _delayedSymLinks; | 404 | // CObjectVector<NWindows::NFile::NDir::CDelayedSymLink> _delayedSymLinks; |
393 | #endif | 405 | #endif |
394 | 406 | ||
395 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(_SFX) | 407 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX) |
396 | bool _saclEnabled; | 408 | bool _saclEnabled; |
397 | #endif | 409 | #endif |
398 | 410 | ||
@@ -425,23 +437,6 @@ public: | |||
425 | 437 | ||
426 | FString DirPathPrefix_for_HashFiles; | 438 | FString DirPathPrefix_for_HashFiles; |
427 | 439 | ||
428 | MY_UNKNOWN_IMP5( | ||
429 | IArchiveExtractCallbackMessage, | ||
430 | ICryptoGetTextPassword, | ||
431 | ICompressProgressInfo, | ||
432 | IArchiveUpdateCallbackFile, | ||
433 | IArchiveGetDiskProperty | ||
434 | ) | ||
435 | |||
436 | INTERFACE_IArchiveExtractCallback(;) | ||
437 | INTERFACE_IArchiveExtractCallbackMessage(;) | ||
438 | INTERFACE_IArchiveUpdateCallbackFile(;) | ||
439 | INTERFACE_IArchiveGetDiskProperty(;) | ||
440 | |||
441 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); | ||
442 | |||
443 | STDMETHOD(CryptoGetTextPassword)(BSTR *password); | ||
444 | |||
445 | CArchiveExtractCallback(); | 440 | CArchiveExtractCallback(); |
446 | 441 | ||
447 | void InitForMulti(bool multiArchives, | 442 | void InitForMulti(bool multiArchives, |
@@ -462,7 +457,7 @@ public: | |||
462 | NumFolders = NumFiles = NumAltStreams = UnpackSize = AltStreams_UnpackSize = 0; | 457 | NumFolders = NumFiles = NumAltStreams = UnpackSize = AltStreams_UnpackSize = 0; |
463 | } | 458 | } |
464 | 459 | ||
465 | #ifndef _SFX | 460 | #ifndef Z7_SFX |
466 | 461 | ||
467 | void SetHashMethods(IHashCalc *hash) | 462 | void SetHashMethods(IHashCalc *hash) |
468 | { | 463 | { |
@@ -494,7 +489,7 @@ private: | |||
494 | CHardLinks _hardLinks; | 489 | CHardLinks _hardLinks; |
495 | CLinkInfo _link; | 490 | CLinkInfo _link; |
496 | 491 | ||
497 | // FString _CopyFile_Path; | 492 | // FString _copyFile_Path; |
498 | // HRESULT MyCopyFile(ISequentialOutStream *outStream); | 493 | // HRESULT MyCopyFile(ISequentialOutStream *outStream); |
499 | HRESULT Link(const FString &fullProcessedPath); | 494 | HRESULT Link(const FString &fullProcessedPath); |
500 | HRESULT ReadLink(); | 495 | HRESULT ReadLink(); |
@@ -512,7 +507,7 @@ public: | |||
512 | 507 | ||
513 | // call it after Init() | 508 | // call it after Init() |
514 | 509 | ||
515 | #ifndef _SFX | 510 | #ifndef Z7_SFX |
516 | void SetBaseParentFolderIndex(UInt32 indexInArc) | 511 | void SetBaseParentFolderIndex(UInt32 indexInArc) |
517 | { | 512 | { |
518 | _baseParentFolder = indexInArc; | 513 | _baseParentFolder = indexInArc; |
diff --git a/CPP/7zip/UI/Common/ArchiveName.cpp b/CPP/7zip/UI/Common/ArchiveName.cpp index 1baf3e1..1c0c3a8 100644 --- a/CPP/7zip/UI/Common/ArchiveName.cpp +++ b/CPP/7zip/UI/Common/ArchiveName.cpp | |||
@@ -2,154 +2,175 @@ | |||
2 | 2 | ||
3 | #include "StdAfx.h" | 3 | #include "StdAfx.h" |
4 | 4 | ||
5 | #include "../../../../C/Sort.h" | ||
6 | |||
5 | #include "../../../Common/Wildcard.h" | 7 | #include "../../../Common/Wildcard.h" |
8 | #include "../../../Common/StringToInt.h" | ||
6 | 9 | ||
7 | #include "../../../Windows/FileDir.h" | 10 | #include "../../../Windows/FileDir.h" |
8 | #include "../../../Windows/FileName.h" | 11 | #include "../../../Windows/FileName.h" |
9 | 12 | ||
10 | #include "ExtractingFilePath.h" | ||
11 | #include "ArchiveName.h" | 13 | #include "ArchiveName.h" |
14 | #include "ExtractingFilePath.h" | ||
12 | 15 | ||
13 | using namespace NWindows; | 16 | using namespace NWindows; |
14 | using namespace NFile; | 17 | using namespace NFile; |
15 | 18 | ||
16 | static UString CreateArchiveName(const NFind::CFileInfo &fi, bool keepName) | 19 | |
20 | static const char *g_ArcExts = | ||
21 | "7z" | ||
22 | "\0" "zip" | ||
23 | "\0" "tar" | ||
24 | "\0" "wim" | ||
25 | "\0"; | ||
26 | |||
27 | static const char *g_HashExts = | ||
28 | "sha256" | ||
29 | "\0"; | ||
30 | |||
31 | |||
32 | UString CreateArchiveName( | ||
33 | const UStringVector &paths, | ||
34 | bool isHash, | ||
35 | const NFind::CFileInfo *fi, | ||
36 | UString &baseName) | ||
17 | { | 37 | { |
18 | FString resultName = fi.Name; | 38 | bool keepName = isHash; |
19 | if (!fi.IsDir() && !keepName) | 39 | /* |
40 | if (paths.Size() == 1) | ||
20 | { | 41 | { |
21 | int dotPos = resultName.ReverseFind_Dot(); | 42 | const UString &name = paths[0]; |
22 | if (dotPos > 0) | 43 | if (name.Len() > 4) |
23 | { | 44 | if (CompareFileNames(name.RightPtr(4), L".tar") == 0) |
24 | FString archiveName2 = resultName.Left((unsigned)dotPos); | 45 | keepName = true; |
25 | if (archiveName2.ReverseFind_Dot() < 0) | ||
26 | resultName = archiveName2; | ||
27 | } | ||
28 | } | 46 | } |
29 | return Get_Correct_FsFile_Name(fs2us(resultName)); | 47 | */ |
30 | } | ||
31 | 48 | ||
32 | static FString CreateArchiveName2(const FString &path, bool fromPrev, bool keepName) | 49 | UString name ("Archive"); |
33 | { | 50 | NFind::CFileInfo fi3; |
34 | FString resultName ("Archive"); | 51 | if (paths.Size() > 1) |
35 | if (fromPrev) | 52 | fi = NULL; |
53 | if (!fi && paths.Size() != 0) | ||
36 | { | 54 | { |
37 | FString dirPrefix; | 55 | const UString &path = paths.Front(); |
38 | if (NDir::GetOnlyDirPrefix(path, dirPrefix)) | 56 | if (paths.Size() == 1) |
39 | { | 57 | { |
40 | if (!dirPrefix.IsEmpty() && IsPathSepar(dirPrefix.Back())) | 58 | if (fi3.Find(us2fs(path))) |
41 | { | 59 | fi = &fi3; |
42 | #if defined(_WIN32) && !defined(UNDER_CE) | ||
43 | if (NName::IsDriveRootPath_SuperAllowed(dirPrefix)) | ||
44 | resultName = dirPrefix[dirPrefix.Len() - 3]; // only letter | ||
45 | else | ||
46 | #endif | ||
47 | { | ||
48 | dirPrefix.DeleteBack(); | ||
49 | NFind::CFileInfo fi; | ||
50 | if (fi.Find(dirPrefix)) | ||
51 | resultName = fi.Name; | ||
52 | } | ||
53 | } | ||
54 | } | 60 | } |
55 | } | 61 | else |
56 | else | ||
57 | { | ||
58 | NFind::CFileInfo fi; | ||
59 | if (fi.Find(path)) | ||
60 | { | 62 | { |
61 | resultName = fi.Name; | 63 | // we try to use name of parent folder |
62 | if (!fi.IsDir() && !keepName) | 64 | FString dirPrefix; |
65 | if (NDir::GetOnlyDirPrefix(us2fs(path), dirPrefix)) | ||
63 | { | 66 | { |
64 | int dotPos = resultName.ReverseFind_Dot(); | 67 | if (!dirPrefix.IsEmpty() && IsPathSepar(dirPrefix.Back())) |
65 | if (dotPos > 0) | ||
66 | { | 68 | { |
67 | FString name2 = resultName.Left((unsigned)dotPos); | 69 | #if defined(_WIN32) && !defined(UNDER_CE) |
68 | if (name2.ReverseFind_Dot() < 0) | 70 | if (NName::IsDriveRootPath_SuperAllowed(dirPrefix)) |
69 | resultName = name2; | 71 | { |
72 | if (path != fs2us(dirPrefix)) | ||
73 | name = dirPrefix[dirPrefix.Len() - 3]; // only letter | ||
74 | } | ||
75 | else | ||
76 | #endif | ||
77 | { | ||
78 | dirPrefix.DeleteBack(); | ||
79 | if (!dirPrefix.IsEmpty()) | ||
80 | { | ||
81 | const int slash = dirPrefix.ReverseFind_PathSepar(); | ||
82 | if (slash >= 0 && slash != (int)dirPrefix.Len() - 1) | ||
83 | name = dirPrefix.Ptr(slash + 1); | ||
84 | else if (fi3.Find(dirPrefix)) | ||
85 | name = fs2us(fi3.Name); | ||
86 | } | ||
87 | } | ||
70 | } | 88 | } |
71 | } | 89 | } |
72 | } | 90 | } |
73 | } | 91 | } |
74 | return resultName; | ||
75 | } | ||
76 | |||
77 | 92 | ||
78 | UString CreateArchiveName(const UStringVector &paths, const NFind::CFileInfo *fi) | ||
79 | { | ||
80 | bool keepName = false; | ||
81 | /* | ||
82 | if (paths.Size() == 1) | ||
83 | { | ||
84 | const UString &name = paths[0]; | ||
85 | if (name.Len() > 4) | ||
86 | if (CompareFileNames(name.RightPtr(4), L".tar") == 0) | ||
87 | keepName = true; | ||
88 | } | ||
89 | */ | ||
90 | |||
91 | UString name; | ||
92 | if (fi) | 93 | if (fi) |
93 | name = CreateArchiveName(*fi, keepName); | ||
94 | else | ||
95 | { | 94 | { |
96 | if (paths.IsEmpty()) | 95 | name = fs2us(fi->Name); |
97 | return L"archive"; | 96 | if (!fi->IsDir() && !keepName) |
98 | bool fromPrev = (paths.Size() > 1); | 97 | { |
99 | name = Get_Correct_FsFile_Name(fs2us(CreateArchiveName2(us2fs(paths.Front()), fromPrev, keepName))); | 98 | const int dotPos = name.Find(L'.'); |
99 | if (dotPos > 0 && name.Find(L'.', (unsigned)dotPos + 1) < 0) | ||
100 | name.DeleteFrom((unsigned)dotPos); | ||
101 | } | ||
100 | } | 102 | } |
103 | name = Get_Correct_FsFile_Name(name); | ||
101 | 104 | ||
102 | UStringVector names; | 105 | CRecordVector<UInt32> ids; |
103 | 106 | bool simple_IsAllowed = true; | |
107 | // for (int y = 0; y < 10000; y++) // for debug | ||
104 | { | 108 | { |
109 | // ids.Clear(); | ||
110 | UString n; | ||
111 | |||
105 | FOR_VECTOR (i, paths) | 112 | FOR_VECTOR (i, paths) |
106 | { | 113 | { |
107 | NFind::CFileInfo fi2; | 114 | const UString &a = paths[i]; |
108 | const NFind::CFileInfo *fp; | 115 | const int slash = a.ReverseFind_PathSepar(); |
109 | if (fi && paths.Size() == 1) | 116 | // if (name.Len() >= a.Len() - slash + 1) continue; |
110 | fp = fi; | 117 | const wchar_t *s = a.Ptr(slash + 1); |
111 | else | 118 | if (!IsPath1PrefixedByPath2(s, name)) |
119 | continue; | ||
120 | s += name.Len(); | ||
121 | const char *exts = isHash ? g_HashExts : g_ArcExts; | ||
122 | |||
123 | for (;;) | ||
112 | { | 124 | { |
113 | if (!fi2.Find(us2fs(paths[i]))) | 125 | const char *ext = exts; |
126 | const unsigned len = MyStringLen(ext); | ||
127 | if (len == 0) | ||
128 | break; | ||
129 | exts += len + 1; | ||
130 | n = s; | ||
131 | if (n.Len() <= len) | ||
132 | continue; | ||
133 | if (!StringsAreEqualNoCase_Ascii(n.RightPtr(len), ext)) | ||
134 | continue; | ||
135 | n.DeleteFrom(n.Len() - len); | ||
136 | if (n.Back() != '.') | ||
137 | continue; | ||
138 | n.DeleteBack(); | ||
139 | if (n.IsEmpty()) | ||
140 | { | ||
141 | simple_IsAllowed = false; | ||
142 | break; | ||
143 | } | ||
144 | if (n.Len() < 2) | ||
145 | continue; | ||
146 | if (n[0] != '_') | ||
114 | continue; | 147 | continue; |
115 | fp = &fi2; | 148 | const wchar_t *end; |
149 | const UInt32 v = ConvertStringToUInt32(n.Ptr(1), &end); | ||
150 | if (*end != 0) | ||
151 | continue; | ||
152 | ids.Add(v); | ||
153 | break; | ||
116 | } | 154 | } |
117 | names.Add(fs2us(fp->Name)); | ||
118 | } | 155 | } |
119 | } | 156 | } |
120 | 157 | ||
121 | UString postfix; | 158 | baseName = name; |
122 | UInt32 index = 1; | 159 | if (!simple_IsAllowed) |
123 | |||
124 | for (;;) | ||
125 | { | 160 | { |
126 | // we don't want cases when we include archive to itself. | 161 | HeapSort(&ids.Front(), ids.Size()); |
127 | // so we find first available name for archive | 162 | UInt32 v = 2; |
128 | const UString name2 = name + postfix; | 163 | const unsigned num = ids.Size(); |
129 | const UString name2_zip = name2 + L".zip"; | 164 | for (unsigned i = 0; i < num; i++) |
130 | const UString name2_7z = name2 + L".7z"; | ||
131 | const UString name2_tar = name2 + L".tar"; | ||
132 | const UString name2_wim = name2 + L".wim"; | ||
133 | |||
134 | unsigned i = 0; | ||
135 | |||
136 | for (i = 0; i < names.Size(); i++) | ||
137 | { | 165 | { |
138 | const UString &fname = names[i]; | 166 | const UInt32 id = ids[i]; |
139 | if ( 0 == CompareFileNames(fname, name2_zip) | 167 | if (id > v) |
140 | || 0 == CompareFileNames(fname, name2_7z) | ||
141 | || 0 == CompareFileNames(fname, name2_tar) | ||
142 | || 0 == CompareFileNames(fname, name2_wim)) | ||
143 | break; | 168 | break; |
169 | if (id == v) | ||
170 | v = id + 1; | ||
144 | } | 171 | } |
145 | 172 | name += '_'; | |
146 | if (i == names.Size()) | 173 | name.Add_UInt32(v); |
147 | break; | ||
148 | index++; | ||
149 | postfix = "_"; | ||
150 | postfix.Add_UInt32(index); | ||
151 | } | 174 | } |
152 | |||
153 | name += postfix; | ||
154 | return name; | 175 | return name; |
155 | } | 176 | } |
diff --git a/CPP/7zip/UI/Common/ArchiveName.h b/CPP/7zip/UI/Common/ArchiveName.h index 0d32645..9b6b7fe 100644 --- a/CPP/7zip/UI/Common/ArchiveName.h +++ b/CPP/7zip/UI/Common/ArchiveName.h | |||
@@ -1,10 +1,16 @@ | |||
1 | // ArchiveName.h | 1 | // ArchiveName.h |
2 | 2 | ||
3 | #ifndef __ARCHIVE_NAME_H | 3 | #ifndef ZIP7_INC_ARCHIVE_NAME_H |
4 | #define __ARCHIVE_NAME_H | 4 | #define ZIP7_INC_ARCHIVE_NAME_H |
5 | 5 | ||
6 | #include "../../../Windows/FileFind.h" | 6 | #include "../../../Windows/FileFind.h" |
7 | 7 | ||
8 | UString CreateArchiveName(const UStringVector &paths, const NWindows::NFile::NFind::CFileInfo *fi = NULL); | 8 | /* (fi != NULL) only if (paths.Size() == 1) */ |
9 | |||
10 | UString CreateArchiveName( | ||
11 | const UStringVector &paths, | ||
12 | bool isHash, | ||
13 | const NWindows::NFile::NFind::CFileInfo *fi, | ||
14 | UString &baseName); | ||
9 | 15 | ||
10 | #endif | 16 | #endif |
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp index 64aa987..4e5f1f5 100644 --- a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp +++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp | |||
@@ -6,14 +6,54 @@ | |||
6 | 6 | ||
7 | #include "../../../Windows/FileName.h" | 7 | #include "../../../Windows/FileName.h" |
8 | #include "../../../Windows/PropVariant.h" | 8 | #include "../../../Windows/PropVariant.h" |
9 | #include "../../../Windows/System.h" | ||
9 | 10 | ||
10 | #include "../../Common/FileStreams.h" | 11 | #include "../../Common/StreamUtils.h" |
11 | 12 | ||
12 | #include "ArchiveOpenCallback.h" | 13 | #include "ArchiveOpenCallback.h" |
13 | 14 | ||
15 | // #define DEBUG_VOLUMES | ||
16 | |||
17 | #ifdef DEBUG_VOLUMES | ||
18 | #include <stdio.h> | ||
19 | #endif | ||
20 | |||
21 | |||
22 | #ifdef DEBUG_VOLUMES | ||
23 | #define PRF(x) x | ||
24 | #else | ||
25 | #define PRF(x) | ||
26 | #endif | ||
27 | |||
14 | using namespace NWindows; | 28 | using namespace NWindows; |
15 | 29 | ||
16 | STDMETHODIMP COpenCallbackImp::SetTotal(const UInt64 *files, const UInt64 *bytes) | 30 | HRESULT COpenCallbackImp::Init2(const FString &folderPrefix, const FString &fileName) |
31 | { | ||
32 | Volumes.Init(); | ||
33 | FileNames.Clear(); | ||
34 | FileNames_WasUsed.Clear(); | ||
35 | FileSizes.Clear(); | ||
36 | _subArchiveMode = false; | ||
37 | // TotalSize = 0; | ||
38 | PasswordWasAsked = false; | ||
39 | _folderPrefix = folderPrefix; | ||
40 | if (!_fileInfo.Find_FollowLink(_folderPrefix + fileName)) | ||
41 | { | ||
42 | // throw 20121118; | ||
43 | return GetLastError_noZero_HRESULT(); | ||
44 | } | ||
45 | return S_OK; | ||
46 | } | ||
47 | |||
48 | Z7_COM7F_IMF(COpenCallbackImp::SetSubArchiveName(const wchar_t *name)) | ||
49 | { | ||
50 | _subArchiveMode = true; | ||
51 | _subArchiveName = name; | ||
52 | // TotalSize = 0; | ||
53 | return S_OK; | ||
54 | } | ||
55 | |||
56 | Z7_COM7F_IMF(COpenCallbackImp::SetTotal(const UInt64 *files, const UInt64 *bytes)) | ||
17 | { | 57 | { |
18 | COM_TRY_BEGIN | 58 | COM_TRY_BEGIN |
19 | if (ReOpenCallback) | 59 | if (ReOpenCallback) |
@@ -24,7 +64,7 @@ STDMETHODIMP COpenCallbackImp::SetTotal(const UInt64 *files, const UInt64 *bytes | |||
24 | COM_TRY_END | 64 | COM_TRY_END |
25 | } | 65 | } |
26 | 66 | ||
27 | STDMETHODIMP COpenCallbackImp::SetCompleted(const UInt64 *files, const UInt64 *bytes) | 67 | Z7_COM7F_IMF(COpenCallbackImp::SetCompleted(const UInt64 *files, const UInt64 *bytes)) |
28 | { | 68 | { |
29 | COM_TRY_BEGIN | 69 | COM_TRY_BEGIN |
30 | if (ReOpenCallback) | 70 | if (ReOpenCallback) |
@@ -36,7 +76,7 @@ STDMETHODIMP COpenCallbackImp::SetCompleted(const UInt64 *files, const UInt64 *b | |||
36 | } | 76 | } |
37 | 77 | ||
38 | 78 | ||
39 | STDMETHODIMP COpenCallbackImp::GetProperty(PROPID propID, PROPVARIANT *value) | 79 | Z7_COM7F_IMF(COpenCallbackImp::GetProperty(PROPID propID, PROPVARIANT *value)) |
40 | { | 80 | { |
41 | COM_TRY_BEGIN | 81 | COM_TRY_BEGIN |
42 | NCOM::CPropVariant prop; | 82 | NCOM::CPropVariant prop; |
@@ -63,24 +103,180 @@ STDMETHODIMP COpenCallbackImp::GetProperty(PROPID propID, PROPVARIANT *value) | |||
63 | COM_TRY_END | 103 | COM_TRY_END |
64 | } | 104 | } |
65 | 105 | ||
66 | struct CInFileStreamVol: public CInFileStream | 106 | |
67 | { | 107 | // ---------- CInFileStreamVol ---------- |
68 | unsigned FileNameIndex; | 108 | |
109 | Z7_CLASS_IMP_COM_2( | ||
110 | CInFileStreamVol | ||
111 | , IInStream | ||
112 | , IStreamGetSize | ||
113 | ) | ||
114 | Z7_IFACE_COM7_IMP(ISequentialInStream) | ||
115 | public: | ||
116 | unsigned FileIndex; | ||
69 | COpenCallbackImp *OpenCallbackImp; | 117 | COpenCallbackImp *OpenCallbackImp; |
70 | CMyComPtr<IArchiveOpenCallback> OpenCallbackRef; | 118 | CMyComPtr<IArchiveOpenCallback> OpenCallbackRef; |
71 | 119 | ||
120 | HRESULT EnsureOpen() | ||
121 | { | ||
122 | return OpenCallbackImp->Volumes.EnsureOpen(FileIndex); | ||
123 | } | ||
124 | |||
72 | ~CInFileStreamVol() | 125 | ~CInFileStreamVol() |
73 | { | 126 | { |
74 | if (OpenCallbackRef) | 127 | if (OpenCallbackRef) |
75 | OpenCallbackImp->FileNames_WasUsed[FileNameIndex] = false; | 128 | OpenCallbackImp->AtCloseFile(FileIndex); |
76 | } | 129 | } |
77 | }; | 130 | }; |
78 | 131 | ||
79 | 132 | ||
133 | void CMultiStreams::InsertToList(unsigned index) | ||
134 | { | ||
135 | { | ||
136 | CSubStream &s = Streams[index]; | ||
137 | s.Next = Head; | ||
138 | s.Prev = -1; | ||
139 | } | ||
140 | if (Head != -1) | ||
141 | Streams[(unsigned)Head].Prev = (int)index; | ||
142 | else | ||
143 | { | ||
144 | // if (Tail != -1) throw 1; | ||
145 | Tail = (int)index; | ||
146 | } | ||
147 | Head = (int)index; | ||
148 | NumListItems++; | ||
149 | } | ||
150 | |||
151 | // s must bee in List | ||
152 | void CMultiStreams::RemoveFromList(CSubStream &s) | ||
153 | { | ||
154 | if (s.Next != -1) Streams[(unsigned)s.Next].Prev = s.Prev; else Tail = s.Prev; | ||
155 | if (s.Prev != -1) Streams[(unsigned)s.Prev].Next = s.Next; else Head = s.Next; | ||
156 | s.Next = -1; // optional | ||
157 | s.Prev = -1; // optional | ||
158 | NumListItems--; | ||
159 | } | ||
160 | |||
161 | void CMultiStreams::CloseFile(unsigned index) | ||
162 | { | ||
163 | CSubStream &s = Streams[index]; | ||
164 | if (s.Stream) | ||
165 | { | ||
166 | s.Stream.Release(); | ||
167 | RemoveFromList(s); | ||
168 | // s.InFile->Close(); | ||
169 | // s.IsOpen = false; | ||
170 | #ifdef DEBUG_VOLUMES | ||
171 | static int numClosing = 0; | ||
172 | numClosing++; | ||
173 | printf("\nCloseFile %u, total_closes = %u, num_open_files = %u\n", index, numClosing, NumListItems); | ||
174 | #endif | ||
175 | } | ||
176 | } | ||
177 | |||
178 | void CMultiStreams::Init() | ||
179 | { | ||
180 | Head = -1; | ||
181 | Tail = -1; | ||
182 | NumListItems = 0; | ||
183 | Streams.Clear(); | ||
184 | } | ||
185 | |||
186 | CMultiStreams::CMultiStreams(): | ||
187 | Head(-1), | ||
188 | Tail(-1), | ||
189 | NumListItems(0) | ||
190 | { | ||
191 | NumOpenFiles_AllowedMax = NSystem::Get_File_OPEN_MAX_Reduced_for_3_tasks(); | ||
192 | PRF(printf("\nNumOpenFiles_Limit = %u\n", NumOpenFiles_AllowedMax)); | ||
193 | } | ||
194 | |||
195 | |||
196 | HRESULT CMultiStreams::PrepareToOpenNew() | ||
197 | { | ||
198 | if (NumListItems < NumOpenFiles_AllowedMax) | ||
199 | return S_OK; | ||
200 | if (Tail == -1) | ||
201 | return E_FAIL; | ||
202 | CMultiStreams::CSubStream &tailStream = Streams[(unsigned)Tail]; | ||
203 | RINOK(InStream_GetPos(tailStream.Stream, tailStream.LocalPos)) | ||
204 | CloseFile((unsigned)Tail); | ||
205 | return S_OK; | ||
206 | } | ||
207 | |||
208 | |||
209 | HRESULT CMultiStreams::EnsureOpen(unsigned index) | ||
210 | { | ||
211 | CMultiStreams::CSubStream &s = Streams[index]; | ||
212 | if (s.Stream) | ||
213 | { | ||
214 | if ((int)index != Head) | ||
215 | { | ||
216 | RemoveFromList(s); | ||
217 | InsertToList(index); | ||
218 | } | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | RINOK(PrepareToOpenNew()) | ||
223 | { | ||
224 | CInFileStream *inFile = new CInFileStream; | ||
225 | CMyComPtr<IInStream> inStreamTemp = inFile; | ||
226 | if (!inFile->Open(s.Path)) | ||
227 | return GetLastError_noZero_HRESULT(); | ||
228 | s.FileSpec = inFile; | ||
229 | s.Stream = s.FileSpec; | ||
230 | InsertToList(index); | ||
231 | } | ||
232 | // s.IsOpen = true; | ||
233 | if (s.LocalPos != 0) | ||
234 | { | ||
235 | RINOK(s.Stream->Seek((Int64)s.LocalPos, STREAM_SEEK_SET, &s.LocalPos)) | ||
236 | } | ||
237 | #ifdef DEBUG_VOLUMES | ||
238 | static int numOpens = 0; | ||
239 | numOpens++; | ||
240 | printf("\n-- %u, ReOpen, total_reopens = %u, num_open_files = %u\n", index, numOpens, NumListItems); | ||
241 | #endif | ||
242 | } | ||
243 | return S_OK; | ||
244 | } | ||
245 | |||
246 | |||
247 | Z7_COM7F_IMF(CInFileStreamVol::Read(void *data, UInt32 size, UInt32 *processedSize)) | ||
248 | { | ||
249 | if (processedSize) | ||
250 | *processedSize = 0; | ||
251 | if (size == 0) | ||
252 | return S_OK; | ||
253 | RINOK(EnsureOpen()) | ||
254 | CMultiStreams::CSubStream &s = OpenCallbackImp->Volumes.Streams[FileIndex]; | ||
255 | PRF(printf("\n== %u, Read =%u \n", FileIndex, size)); | ||
256 | return s.Stream->Read(data, size, processedSize); | ||
257 | } | ||
258 | |||
259 | Z7_COM7F_IMF(CInFileStreamVol::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)) | ||
260 | { | ||
261 | // if (seekOrigin >= 3) return STG_E_INVALIDFUNCTION; | ||
262 | RINOK(EnsureOpen()) | ||
263 | CMultiStreams::CSubStream &s = OpenCallbackImp->Volumes.Streams[FileIndex]; | ||
264 | PRF(printf("\n-- %u, Seek seekOrigin=%u Seek =%u\n", FileIndex, seekOrigin, (unsigned)offset)); | ||
265 | return s.Stream->Seek(offset, seekOrigin, newPosition); | ||
266 | } | ||
267 | |||
268 | Z7_COM7F_IMF(CInFileStreamVol::GetSize(UInt64 *size)) | ||
269 | { | ||
270 | RINOK(EnsureOpen()) | ||
271 | CMultiStreams::CSubStream &s = OpenCallbackImp->Volumes.Streams[FileIndex]; | ||
272 | return s.FileSpec->GetSize(size); | ||
273 | } | ||
274 | |||
275 | |||
80 | // from ArchiveExtractCallback.cpp | 276 | // from ArchiveExtractCallback.cpp |
81 | bool IsSafePath(const UString &path); | 277 | bool IsSafePath(const UString &path); |
82 | 278 | ||
83 | STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream) | 279 | Z7_COM7F_IMF(COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream)) |
84 | { | 280 | { |
85 | COM_TRY_BEGIN | 281 | COM_TRY_BEGIN |
86 | *inStream = NULL; | 282 | *inStream = NULL; |
@@ -89,13 +285,13 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre | |||
89 | return S_FALSE; | 285 | return S_FALSE; |
90 | if (Callback) | 286 | if (Callback) |
91 | { | 287 | { |
92 | RINOK(Callback->Open_CheckBreak()); | 288 | RINOK(Callback->Open_CheckBreak()) |
93 | } | 289 | } |
94 | 290 | ||
95 | UString name2 = name; | 291 | UString name2 = name; |
96 | 292 | ||
97 | 293 | ||
98 | #ifndef _SFX | 294 | #ifndef Z7_SFX |
99 | 295 | ||
100 | #ifdef _WIN32 | 296 | #ifdef _WIN32 |
101 | name2.Replace(L'/', WCHAR_PATH_SEPARATOR); | 297 | name2.Replace(L'/', WCHAR_PATH_SEPARATOR); |
@@ -112,7 +308,7 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre | |||
112 | if (name2.Find(L'*') >= 0) | 308 | if (name2.Find(L'*') >= 0) |
113 | return S_FALSE; | 309 | return S_FALSE; |
114 | { | 310 | { |
115 | int startPos = 0; | 311 | unsigned startPos = 0; |
116 | if (name2.IsPrefixedBy_Ascii_NoCase("\\\\?\\")) | 312 | if (name2.IsPrefixedBy_Ascii_NoCase("\\\\?\\")) |
117 | startPos = 3; | 313 | startPos = 3; |
118 | if (name2.Find(L'?', startPos) >= 0) | 314 | if (name2.Find(L'?', startPos) >= 0) |
@@ -130,16 +326,32 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre | |||
130 | return S_FALSE; | 326 | return S_FALSE; |
131 | if (_fileInfo.IsDir()) | 327 | if (_fileInfo.IsDir()) |
132 | return S_FALSE; | 328 | return S_FALSE; |
133 | CInFileStreamVol *inFile = new CInFileStreamVol; | 329 | |
134 | CMyComPtr<IInStream> inStreamTemp = inFile; | 330 | CMultiStreams::CSubStream s; |
135 | if (!inFile->Open(fullPath)) | 331 | |
136 | { | 332 | { |
137 | return GetLastError_noZero_HRESULT(); | 333 | CInFileStream *inFile = new CInFileStream; |
334 | CMyComPtr<IInStream> inStreamTemp = inFile; | ||
335 | if (!inFile->Open(fullPath)) | ||
336 | return GetLastError_noZero_HRESULT(); | ||
337 | RINOK(Volumes.PrepareToOpenNew()) | ||
338 | s.FileSpec = inFile; | ||
339 | s.Stream = s.FileSpec; | ||
340 | s.Path = fullPath; | ||
341 | // s.Size = _fileInfo.Size; | ||
342 | // s.IsOpen = true; | ||
138 | } | 343 | } |
139 | 344 | ||
345 | const unsigned fileIndex = Volumes.Streams.Add(s); | ||
346 | Volumes.InsertToList(fileIndex); | ||
347 | |||
140 | FileSizes.Add(_fileInfo.Size); | 348 | FileSizes.Add(_fileInfo.Size); |
141 | FileNames.Add(name2); | 349 | FileNames.Add(name2); |
142 | inFile->FileNameIndex = FileNames_WasUsed.Add(true); | 350 | FileNames_WasUsed.Add(true); |
351 | |||
352 | CInFileStreamVol *inFile = new CInFileStreamVol; | ||
353 | CMyComPtr<IInStream> inStreamTemp = inFile; | ||
354 | inFile->FileIndex = fileIndex; | ||
143 | inFile->OpenCallbackImp = this; | 355 | inFile->OpenCallbackImp = this; |
144 | inFile->OpenCallbackRef = this; | 356 | inFile->OpenCallbackRef = this; |
145 | // TotalSize += _fileInfo.Size; | 357 | // TotalSize += _fileInfo.Size; |
@@ -148,14 +360,16 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre | |||
148 | COM_TRY_END | 360 | COM_TRY_END |
149 | } | 361 | } |
150 | 362 | ||
151 | #ifndef _NO_CRYPTO | 363 | |
152 | STDMETHODIMP COpenCallbackImp::CryptoGetTextPassword(BSTR *password) | 364 | #ifndef Z7_NO_CRYPTO |
365 | Z7_COM7F_IMF(COpenCallbackImp::CryptoGetTextPassword(BSTR *password)) | ||
153 | { | 366 | { |
154 | COM_TRY_BEGIN | 367 | COM_TRY_BEGIN |
155 | if (ReOpenCallback) | 368 | if (ReOpenCallback) |
156 | { | 369 | { |
157 | CMyComPtr<ICryptoGetTextPassword> getTextPassword; | 370 | Z7_DECL_CMyComPtr_QI_FROM( |
158 | ReOpenCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword); | 371 | ICryptoGetTextPassword, |
372 | getTextPassword, ReOpenCallback) | ||
159 | if (getTextPassword) | 373 | if (getTextPassword) |
160 | return getTextPassword->CryptoGetTextPassword(password); | 374 | return getTextPassword->CryptoGetTextPassword(password); |
161 | } | 375 | } |
@@ -166,3 +380,14 @@ STDMETHODIMP COpenCallbackImp::CryptoGetTextPassword(BSTR *password) | |||
166 | COM_TRY_END | 380 | COM_TRY_END |
167 | } | 381 | } |
168 | #endif | 382 | #endif |
383 | |||
384 | // IProgress | ||
385 | Z7_COM7F_IMF(COpenCallbackImp::SetTotal(const UInt64 /* total */)) | ||
386 | { | ||
387 | return S_OK; | ||
388 | } | ||
389 | |||
390 | Z7_COM7F_IMF(COpenCallbackImp::SetCompleted(const UInt64 * /* completed */)) | ||
391 | { | ||
392 | return S_OK; | ||
393 | } | ||
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.h b/CPP/7zip/UI/Common/ArchiveOpenCallback.h index 46b2676..4e44c9d 100644 --- a/CPP/7zip/UI/Common/ArchiveOpenCallback.h +++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.h | |||
@@ -1,112 +1,176 @@ | |||
1 | // ArchiveOpenCallback.h | 1 | // ArchiveOpenCallback.h |
2 | 2 | ||
3 | #ifndef __ARCHIVE_OPEN_CALLBACK_H | 3 | #ifndef ZIP7_INC_ARCHIVE_OPEN_CALLBACK_H |
4 | #define __ARCHIVE_OPEN_CALLBACK_H | 4 | #define ZIP7_INC_ARCHIVE_OPEN_CALLBACK_H |
5 | 5 | ||
6 | #include "../../../Common/MyCom.h" | 6 | #include "../../../Common/MyCom.h" |
7 | 7 | ||
8 | #include "../../../Windows/FileFind.h" | 8 | #include "../../../Windows/FileFind.h" |
9 | #include "../../../Windows/FileIO.h" | ||
10 | 9 | ||
11 | #ifndef _NO_CRYPTO | 10 | #include "../../Common/FileStreams.h" |
11 | |||
12 | #ifndef Z7_NO_CRYPTO | ||
12 | #include "../../IPassword.h" | 13 | #include "../../IPassword.h" |
13 | #endif | 14 | #endif |
14 | #include "../../Archive/IArchive.h" | 15 | #include "../../Archive/IArchive.h" |
15 | 16 | ||
16 | #ifdef _NO_CRYPTO | 17 | Z7_PURE_INTERFACES_BEGIN |
18 | |||
19 | #ifdef Z7_NO_CRYPTO | ||
17 | 20 | ||
18 | #define INTERFACE_IOpenCallbackUI_Crypto(x) | 21 | #define Z7_IFACEM_IOpenCallbackUI_Crypto(x) |
19 | 22 | ||
20 | #else | 23 | #else |
21 | 24 | ||
22 | #define INTERFACE_IOpenCallbackUI_Crypto(x) \ | 25 | #define Z7_IFACEM_IOpenCallbackUI_Crypto(x) \ |
23 | virtual HRESULT Open_CryptoGetTextPassword(BSTR *password) x; \ | 26 | virtual HRESULT Open_CryptoGetTextPassword(BSTR *password) x \ |
24 | /* virtual HRESULT Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password) x; */ \ | 27 | /* virtual HRESULT Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password) x */ \ |
25 | /* virtual bool Open_WasPasswordAsked() x; */ \ | 28 | /* virtual bool Open_WasPasswordAsked() x */ \ |
26 | /* virtual void Open_Clear_PasswordWasAsked_Flag() x; */ \ | 29 | /* virtual void Open_Clear_PasswordWasAsked_Flag() x */ \ |
27 | 30 | ||
28 | #endif | 31 | #endif |
29 | 32 | ||
30 | #define INTERFACE_IOpenCallbackUI(x) \ | 33 | #define Z7_IFACEN_IOpenCallbackUI(x) \ |
31 | virtual HRESULT Open_CheckBreak() x; \ | 34 | virtual HRESULT Open_CheckBreak() x \ |
32 | virtual HRESULT Open_SetTotal(const UInt64 *files, const UInt64 *bytes) x; \ | 35 | virtual HRESULT Open_SetTotal(const UInt64 *files, const UInt64 *bytes) x \ |
33 | virtual HRESULT Open_SetCompleted(const UInt64 *files, const UInt64 *bytes) x; \ | 36 | virtual HRESULT Open_SetCompleted(const UInt64 *files, const UInt64 *bytes) x \ |
34 | virtual HRESULT Open_Finished() x; \ | 37 | virtual HRESULT Open_Finished() x \ |
35 | INTERFACE_IOpenCallbackUI_Crypto(x) | 38 | Z7_IFACEM_IOpenCallbackUI_Crypto(x) |
39 | |||
40 | Z7_IFACE_DECL_PURE(IOpenCallbackUI) | ||
41 | |||
42 | Z7_PURE_INTERFACES_END | ||
43 | |||
36 | 44 | ||
37 | struct IOpenCallbackUI | 45 | class CMultiStreams Z7_final |
38 | { | 46 | { |
39 | INTERFACE_IOpenCallbackUI(=0) | 47 | public: |
48 | struct CSubStream | ||
49 | { | ||
50 | CMyComPtr<IInStream> Stream; | ||
51 | CInFileStream *FileSpec; | ||
52 | FString Path; | ||
53 | // UInt64 Size; | ||
54 | UInt64 LocalPos; | ||
55 | int Next; // next older | ||
56 | int Prev; // prev newer | ||
57 | // bool IsOpen; | ||
58 | |||
59 | CSubStream(): | ||
60 | FileSpec(NULL), | ||
61 | // Size(0), | ||
62 | LocalPos(0), | ||
63 | Next(-1), | ||
64 | Prev(-1) | ||
65 | // IsOpen(false) | ||
66 | {} | ||
67 | }; | ||
68 | |||
69 | CObjectVector<CSubStream> Streams; | ||
70 | private: | ||
71 | // we must use critical section here, if we want to access from different volumnes simultaneously | ||
72 | int Head; // newest | ||
73 | int Tail; // oldest | ||
74 | unsigned NumListItems; | ||
75 | unsigned NumOpenFiles_AllowedMax; | ||
76 | public: | ||
77 | |||
78 | CMultiStreams(); | ||
79 | void Init(); | ||
80 | HRESULT PrepareToOpenNew(); | ||
81 | void InsertToList(unsigned index); | ||
82 | void RemoveFromList(CSubStream &s); | ||
83 | void CloseFile(unsigned index); | ||
84 | HRESULT EnsureOpen(unsigned index); | ||
40 | }; | 85 | }; |
41 | 86 | ||
42 | class COpenCallbackImp: | 87 | |
88 | /* | ||
89 | We need COpenCallbackImp class for multivolume processing. | ||
90 | Also we use it as proxy from COM interfaces (IArchiveOpenCallback) to internal (IOpenCallbackUI) interfaces. | ||
91 | If archive is multivolume: | ||
92 | COpenCallbackImp object will exist after Open stage. | ||
93 | COpenCallbackImp object will be deleted when last reference | ||
94 | from each volume object (CInFileStreamVol) will be closed (when archive will be closed). | ||
95 | */ | ||
96 | |||
97 | class COpenCallbackImp Z7_final: | ||
43 | public IArchiveOpenCallback, | 98 | public IArchiveOpenCallback, |
44 | public IArchiveOpenVolumeCallback, | 99 | public IArchiveOpenVolumeCallback, |
45 | public IArchiveOpenSetSubArchiveName, | 100 | public IArchiveOpenSetSubArchiveName, |
46 | #ifndef _NO_CRYPTO | 101 | #ifndef Z7_NO_CRYPTO |
47 | public ICryptoGetTextPassword, | 102 | public ICryptoGetTextPassword, |
48 | #endif | 103 | #endif |
104 | public IProgress, // IProgress is used for 7zFM | ||
49 | public CMyUnknownImp | 105 | public CMyUnknownImp |
50 | { | 106 | { |
107 | Z7_COM_QI_BEGIN2(IArchiveOpenCallback) | ||
108 | Z7_COM_QI_ENTRY(IArchiveOpenVolumeCallback) | ||
109 | Z7_COM_QI_ENTRY(IArchiveOpenSetSubArchiveName) | ||
110 | #ifndef Z7_NO_CRYPTO | ||
111 | Z7_COM_QI_ENTRY(ICryptoGetTextPassword) | ||
112 | #endif | ||
113 | // Z7_COM_QI_ENTRY(IProgress) // the code doesn't require it | ||
114 | Z7_COM_QI_END | ||
115 | Z7_COM_ADDREF_RELEASE | ||
116 | |||
117 | Z7_IFACE_COM7_IMP(IArchiveOpenCallback) | ||
118 | Z7_IFACE_COM7_IMP(IArchiveOpenVolumeCallback) | ||
119 | Z7_IFACE_COM7_IMP(IProgress) | ||
51 | public: | 120 | public: |
52 | MY_QUERYINTERFACE_BEGIN2(IArchiveOpenVolumeCallback) | 121 | Z7_IFACE_COM7_IMP(IArchiveOpenSetSubArchiveName) |
53 | MY_QUERYINTERFACE_ENTRY(IArchiveOpenSetSubArchiveName) | ||
54 | #ifndef _NO_CRYPTO | ||
55 | MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword) | ||
56 | #endif | ||
57 | MY_QUERYINTERFACE_END | ||
58 | MY_ADDREF_RELEASE | ||
59 | |||
60 | INTERFACE_IArchiveOpenCallback(;) | ||
61 | INTERFACE_IArchiveOpenVolumeCallback(;) | ||
62 | |||
63 | #ifndef _NO_CRYPTO | ||
64 | STDMETHOD(CryptoGetTextPassword)(BSTR *password); | ||
65 | #endif | ||
66 | |||
67 | STDMETHOD(SetSubArchiveName(const wchar_t *name)) | ||
68 | { | ||
69 | _subArchiveMode = true; | ||
70 | _subArchiveName = name; | ||
71 | // TotalSize = 0; | ||
72 | return S_OK; | ||
73 | } | ||
74 | |||
75 | private: | 122 | private: |
76 | FString _folderPrefix; | 123 | #ifndef Z7_NO_CRYPTO |
77 | NWindows::NFile::NFind::CFileInfo _fileInfo; | 124 | Z7_IFACE_COM7_IMP(ICryptoGetTextPassword) |
125 | #endif | ||
126 | |||
78 | bool _subArchiveMode; | 127 | bool _subArchiveMode; |
79 | UString _subArchiveName; | ||
80 | 128 | ||
81 | public: | 129 | public: |
130 | bool PasswordWasAsked; | ||
82 | UStringVector FileNames; | 131 | UStringVector FileNames; |
83 | CBoolVector FileNames_WasUsed; | 132 | CBoolVector FileNames_WasUsed; |
84 | CRecordVector<UInt64> FileSizes; | 133 | CRecordVector<UInt64> FileSizes; |
85 | |||
86 | bool PasswordWasAsked; | ||
87 | 134 | ||
135 | void AtCloseFile(unsigned fileIndex) | ||
136 | { | ||
137 | FileNames_WasUsed[fileIndex] = false; | ||
138 | Volumes.CloseFile(fileIndex); | ||
139 | } | ||
140 | |||
141 | /* we have two ways to Callback from this object | ||
142 | 1) IArchiveOpenCallback * ReOpenCallback - for ReOpen function, when IOpenCallbackUI is not available | ||
143 | 2) IOpenCallbackUI *Callback - for usual callback | ||
144 | we can't transfer IOpenCallbackUI pointer via internal interface, | ||
145 | so we use ReOpenCallback to callback without IOpenCallbackUI. | ||
146 | */ | ||
147 | |||
148 | /* we use Callback/ReOpenCallback only at Open stage. | ||
149 | So the CMyComPtr reference counter is not required, | ||
150 | and we don't want additional reference to unused object, | ||
151 | if COpenCallbackImp is not closed | ||
152 | */ | ||
153 | IArchiveOpenCallback *ReOpenCallback; | ||
154 | // CMyComPtr<IArchiveOpenCallback> ReOpenCallback; | ||
88 | IOpenCallbackUI *Callback; | 155 | IOpenCallbackUI *Callback; |
89 | CMyComPtr<IArchiveOpenCallback> ReOpenCallback; | 156 | // CMyComPtr<IUnknown> Callback_Ref; |
157 | |||
158 | private: | ||
159 | FString _folderPrefix; | ||
160 | UString _subArchiveName; | ||
161 | NWindows::NFile::NFind::CFileInfo _fileInfo; | ||
162 | |||
163 | public: | ||
164 | CMultiStreams Volumes; | ||
165 | |||
90 | // UInt64 TotalSize; | 166 | // UInt64 TotalSize; |
91 | 167 | ||
92 | COpenCallbackImp(): _subArchiveMode(false), Callback(NULL) {} | 168 | COpenCallbackImp(): |
169 | _subArchiveMode(false), | ||
170 | ReOpenCallback(NULL), | ||
171 | Callback(NULL) {} | ||
93 | 172 | ||
94 | HRESULT Init2(const FString &folderPrefix, const FString &fileName) | 173 | HRESULT Init2(const FString &folderPrefix, const FString &fileName); |
95 | { | ||
96 | FileNames.Clear(); | ||
97 | FileNames_WasUsed.Clear(); | ||
98 | FileSizes.Clear(); | ||
99 | _subArchiveMode = false; | ||
100 | // TotalSize = 0; | ||
101 | PasswordWasAsked = false; | ||
102 | _folderPrefix = folderPrefix; | ||
103 | if (!_fileInfo.Find_FollowLink(_folderPrefix + fileName)) | ||
104 | { | ||
105 | // throw 20121118; | ||
106 | return GetLastError_noZero_HRESULT(); | ||
107 | } | ||
108 | return S_OK; | ||
109 | } | ||
110 | 174 | ||
111 | bool SetSecondFileInfo(CFSTR newName) | 175 | bool SetSecondFileInfo(CFSTR newName) |
112 | { | 176 | { |
diff --git a/CPP/7zip/UI/Common/Bench.cpp b/CPP/7zip/UI/Common/Bench.cpp index cc0cfd0..5da9783 100644 --- a/CPP/7zip/UI/Common/Bench.cpp +++ b/CPP/7zip/UI/Common/Bench.cpp | |||
@@ -36,19 +36,20 @@ | |||
36 | #include "../../../../C/7zCrc.h" | 36 | #include "../../../../C/7zCrc.h" |
37 | #include "../../../../C/RotateDefs.h" | 37 | #include "../../../../C/RotateDefs.h" |
38 | 38 | ||
39 | #ifndef _7ZIP_ST | 39 | #ifndef Z7_ST |
40 | #include "../../../Windows/Synchronization.h" | 40 | #include "../../../Windows/Synchronization.h" |
41 | #include "../../../Windows/Thread.h" | 41 | #include "../../../Windows/Thread.h" |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #include "../../../Windows/FileIO.h" | ||
45 | #include "../../../Windows/FileFind.h" | 44 | #include "../../../Windows/FileFind.h" |
45 | #include "../../../Windows/FileIO.h" | ||
46 | #include "../../../Windows/SystemInfo.h" | 46 | #include "../../../Windows/SystemInfo.h" |
47 | 47 | ||
48 | #include "../../../Common/IntToString.h" | ||
49 | #include "../../../Common/MyBuffer2.h" | 48 | #include "../../../Common/MyBuffer2.h" |
49 | #include "../../../Common/IntToString.h" | ||
50 | #include "../../../Common/StringConvert.h" | 50 | #include "../../../Common/StringConvert.h" |
51 | #include "../../../Common/StringToInt.h" | 51 | #include "../../../Common/StringToInt.h" |
52 | #include "../../../Common/Wildcard.h" | ||
52 | 53 | ||
53 | #include "../../Common/MethodProps.h" | 54 | #include "../../Common/MethodProps.h" |
54 | #include "../../Common/StreamObjects.h" | 55 | #include "../../Common/StreamObjects.h" |
@@ -58,7 +59,7 @@ | |||
58 | 59 | ||
59 | using namespace NWindows; | 60 | using namespace NWindows; |
60 | 61 | ||
61 | #ifndef _7ZIP_ST | 62 | #ifndef Z7_ST |
62 | static const UInt32 k_LZMA = 0x030101; | 63 | static const UInt32 k_LZMA = 0x030101; |
63 | #endif | 64 | #endif |
64 | 65 | ||
@@ -122,7 +123,7 @@ class CBaseRandomGenerator | |||
122 | public: | 123 | public: |
123 | CBaseRandomGenerator(UInt32 salt = 0): Salt(salt) { Init(); } | 124 | CBaseRandomGenerator(UInt32 salt = 0): Salt(salt) { Init(); } |
124 | void Init() { A1 = 362436069; A2 = 521288629;} | 125 | void Init() { A1 = 362436069; A2 = 521288629;} |
125 | MY_FORCE_INLINE | 126 | Z7_FORCE_INLINE |
126 | UInt32 GetRnd() | 127 | UInt32 GetRnd() |
127 | { | 128 | { |
128 | return Salt ^ | 129 | return Salt ^ |
@@ -134,7 +135,7 @@ public: | |||
134 | }; | 135 | }; |
135 | 136 | ||
136 | 137 | ||
137 | MY_NO_INLINE | 138 | Z7_NO_INLINE |
138 | static void RandGen(Byte *buf, size_t size) | 139 | static void RandGen(Byte *buf, size_t size) |
139 | { | 140 | { |
140 | CBaseRandomGenerator RG; | 141 | CBaseRandomGenerator RG; |
@@ -143,7 +144,7 @@ static void RandGen(Byte *buf, size_t size) | |||
143 | for (i = 0; i < size4; i += 4) | 144 | for (i = 0; i < size4; i += 4) |
144 | { | 145 | { |
145 | const UInt32 v = RG.GetRnd(); | 146 | const UInt32 v = RG.GetRnd(); |
146 | SetUi32(buf + i, v); | 147 | SetUi32(buf + i, v) |
147 | } | 148 | } |
148 | UInt32 v = RG.GetRnd(); | 149 | UInt32 v = RG.GetRnd(); |
149 | for (; i < size; i++) | 150 | for (; i < size; i++) |
@@ -255,16 +256,14 @@ public: | |||
255 | }; | 256 | }; |
256 | 257 | ||
257 | 258 | ||
258 | class CBenchmarkInStream: | 259 | Z7_CLASS_IMP_NOQIB_1( |
259 | public ISequentialInStream, | 260 | CBenchmarkInStream |
260 | public CMyUnknownImp | 261 | , ISequentialInStream |
261 | { | 262 | ) |
262 | const Byte *Data; | 263 | const Byte *Data; |
263 | size_t Pos; | 264 | size_t Pos; |
264 | size_t Size; | 265 | size_t Size; |
265 | |||
266 | public: | 266 | public: |
267 | MY_UNKNOWN_IMP | ||
268 | void Init(const Byte *data, size_t size) | 267 | void Init(const Byte *data, size_t size) |
269 | { | 268 | { |
270 | Data = data; | 269 | Data = data; |
@@ -272,10 +271,9 @@ public: | |||
272 | Pos = 0; | 271 | Pos = 0; |
273 | } | 272 | } |
274 | bool WasFinished() const { return Pos == Size; } | 273 | bool WasFinished() const { return Pos == Size; } |
275 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); | ||
276 | }; | 274 | }; |
277 | 275 | ||
278 | STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize) | 276 | Z7_COM7F_IMF(CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize)) |
279 | { | 277 | { |
280 | const UInt32 kMaxBlockSize = (1 << 20); | 278 | const UInt32 kMaxBlockSize = (1 << 20); |
281 | if (size > kMaxBlockSize) | 279 | if (size > kMaxBlockSize) |
@@ -293,11 +291,14 @@ STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processed | |||
293 | return S_OK; | 291 | return S_OK; |
294 | } | 292 | } |
295 | 293 | ||
296 | class CBenchmarkOutStream: | 294 | |
295 | class CBenchmarkOutStream Z7_final: | ||
297 | public ISequentialOutStream, | 296 | public ISequentialOutStream, |
298 | public CMidAlignedBuffer, | 297 | public CMyUnknownImp, |
299 | public CMyUnknownImp | 298 | public CMidAlignedBuffer |
300 | { | 299 | { |
300 | Z7_COM_UNKNOWN_IMP_0 | ||
301 | Z7_IFACE_COM7_IMP(ISequentialOutStream) | ||
301 | // bool _overflow; | 302 | // bool _overflow; |
302 | public: | 303 | public: |
303 | size_t Pos; | 304 | size_t Pos; |
@@ -328,12 +329,9 @@ public: | |||
328 | size_t GetPos() const { return Pos; } | 329 | size_t GetPos() const { return Pos; } |
329 | 330 | ||
330 | // void Print() { printf("\n%8d %8d\n", (unsigned)BufferSize, (unsigned)Pos); } | 331 | // void Print() { printf("\n%8d %8d\n", (unsigned)BufferSize, (unsigned)Pos); } |
331 | |||
332 | MY_UNKNOWN_IMP | ||
333 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | ||
334 | }; | 332 | }; |
335 | 333 | ||
336 | STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) | 334 | Z7_COM7F_IMF(CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)) |
337 | { | 335 | { |
338 | size_t curSize = Size() - Pos; | 336 | size_t curSize = Size() - Pos; |
339 | if (curSize > size) | 337 | if (curSize > size) |
@@ -357,27 +355,24 @@ STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *p | |||
357 | } | 355 | } |
358 | 356 | ||
359 | 357 | ||
360 | class CCrcOutStream: | 358 | Z7_CLASS_IMP_NOQIB_1( |
361 | public ISequentialOutStream, | 359 | CCrcOutStream |
362 | public CMyUnknownImp | 360 | , ISequentialOutStream |
363 | { | 361 | ) |
364 | public: | 362 | public: |
365 | bool CalcCrc; | 363 | bool CalcCrc; |
366 | UInt32 Crc; | 364 | UInt32 Crc; |
367 | UInt64 Pos; | 365 | UInt64 Pos; |
368 | 366 | ||
369 | MY_UNKNOWN_IMP | 367 | CCrcOutStream(): CalcCrc(true) {} |
370 | |||
371 | CCrcOutStream(): CalcCrc(true) {}; | ||
372 | void Init() { Crc = CRC_INIT_VAL; Pos = 0; } | 368 | void Init() { Crc = CRC_INIT_VAL; Pos = 0; } |
373 | void Calc(const void *data, size_t size) | 369 | void Calc(const void *data, size_t size) |
374 | { | 370 | { |
375 | Crc = CrcUpdate(Crc, data, size); | 371 | Crc = CrcUpdate(Crc, data, size); |
376 | } | 372 | } |
377 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | ||
378 | }; | 373 | }; |
379 | 374 | ||
380 | STDMETHODIMP CCrcOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) | 375 | Z7_COM7F_IMF(CCrcOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)) |
381 | { | 376 | { |
382 | if (CalcCrc) | 377 | if (CalcCrc) |
383 | Calc(data, size); | 378 | Calc(data, size); |
@@ -394,7 +389,7 @@ static UInt64 GetTimeCount() | |||
394 | #ifdef USE_POSIX_TIME | 389 | #ifdef USE_POSIX_TIME |
395 | #ifdef USE_POSIX_TIME2 | 390 | #ifdef USE_POSIX_TIME2 |
396 | timeval v; | 391 | timeval v; |
397 | if (gettimeofday(&v, 0) == 0) | 392 | if (gettimeofday(&v, NULL) == 0) |
398 | return (UInt64)(v.tv_sec) * 1000000 + (UInt64)v.tv_usec; | 393 | return (UInt64)(v.tv_sec) * 1000000 + (UInt64)v.tv_usec; |
399 | return (UInt64)time(NULL) * 1000000; | 394 | return (UInt64)time(NULL) * 1000000; |
400 | #else | 395 | #else |
@@ -531,9 +526,9 @@ static UInt64 GetUserFreq() | |||
531 | #endif | 526 | #endif |
532 | } | 527 | } |
533 | 528 | ||
534 | class CBenchProgressStatus | 529 | class CBenchProgressStatus Z7_final |
535 | { | 530 | { |
536 | #ifndef _7ZIP_ST | 531 | #ifndef Z7_ST |
537 | NSynchronization::CCriticalSection CS; | 532 | NSynchronization::CCriticalSection CS; |
538 | #endif | 533 | #endif |
539 | public: | 534 | public: |
@@ -541,14 +536,14 @@ public: | |||
541 | bool EncodeMode; | 536 | bool EncodeMode; |
542 | void SetResult(HRESULT res) | 537 | void SetResult(HRESULT res) |
543 | { | 538 | { |
544 | #ifndef _7ZIP_ST | 539 | #ifndef Z7_ST |
545 | NSynchronization::CCriticalSectionLock lock(CS); | 540 | NSynchronization::CCriticalSectionLock lock(CS); |
546 | #endif | 541 | #endif |
547 | Res = res; | 542 | Res = res; |
548 | } | 543 | } |
549 | HRESULT GetResult() | 544 | HRESULT GetResult() |
550 | { | 545 | { |
551 | #ifndef _7ZIP_ST | 546 | #ifndef Z7_ST |
552 | NSynchronization::CCriticalSectionLock lock(CS); | 547 | NSynchronization::CCriticalSectionLock lock(CS); |
553 | #endif | 548 | #endif |
554 | return Res; | 549 | return Res; |
@@ -580,22 +575,22 @@ void CBenchInfoCalc::SetFinishTime(CBenchInfo &dest) | |||
580 | dest.UserTime = UserTime.GetUserTime(); | 575 | dest.UserTime = UserTime.GetUserTime(); |
581 | } | 576 | } |
582 | 577 | ||
583 | class CBenchProgressInfo: | 578 | class CBenchProgressInfo Z7_final: |
584 | public ICompressProgressInfo, | 579 | public ICompressProgressInfo, |
585 | public CMyUnknownImp, | 580 | public CMyUnknownImp, |
586 | public CBenchInfoCalc | 581 | public CBenchInfoCalc |
587 | { | 582 | { |
583 | Z7_COM_UNKNOWN_IMP_0 | ||
584 | Z7_IFACE_COM7_IMP(ICompressProgressInfo) | ||
588 | public: | 585 | public: |
589 | CBenchProgressStatus *Status; | 586 | CBenchProgressStatus *Status; |
590 | IBenchCallback *Callback; | 587 | IBenchCallback *Callback; |
591 | 588 | ||
592 | CBenchProgressInfo(): Callback(NULL) {} | 589 | CBenchProgressInfo(): Callback(NULL) {} |
593 | MY_UNKNOWN_IMP | ||
594 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); | ||
595 | }; | 590 | }; |
596 | 591 | ||
597 | 592 | ||
598 | STDMETHODIMP CBenchProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) | 593 | Z7_COM7F_IMF(CBenchProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)) |
599 | { | 594 | { |
600 | HRESULT res = Status->GetResult(); | 595 | HRESULT res = Status->GetResult(); |
601 | if (res != S_OK) | 596 | if (res != S_OK) |
@@ -760,13 +755,20 @@ UInt64 CBenchInfo::GetSpeed(UInt64 numUnits) const | |||
760 | return MyMultDiv64(numUnits, GlobalFreq, GlobalTime); | 755 | return MyMultDiv64(numUnits, GlobalFreq, GlobalTime); |
761 | } | 756 | } |
762 | 757 | ||
758 | static UInt64 GetNumCommands_from_Size_and_Complexity(UInt64 size, Int32 complexity) | ||
759 | { | ||
760 | return complexity >= 0 ? | ||
761 | size * (UInt32)complexity : | ||
762 | size / (UInt32)(-complexity); | ||
763 | } | ||
764 | |||
763 | struct CBenchProps | 765 | struct CBenchProps |
764 | { | 766 | { |
765 | bool LzmaRatingMode; | 767 | bool LzmaRatingMode; |
766 | 768 | ||
767 | UInt32 EncComplex; | 769 | Int32 EncComplex; |
768 | UInt32 DecComplexCompr; | 770 | Int32 DecComplexCompr; |
769 | UInt32 DecComplexUnc; | 771 | Int32 DecComplexUnc; |
770 | 772 | ||
771 | unsigned KeySize; | 773 | unsigned KeySize; |
772 | 774 | ||
@@ -777,21 +779,23 @@ struct CBenchProps | |||
777 | 779 | ||
778 | void SetLzmaCompexity(); | 780 | void SetLzmaCompexity(); |
779 | 781 | ||
780 | UInt64 GeComprCommands(UInt64 unpackSize) | 782 | UInt64 GetNumCommands_Enc(UInt64 unpackSize) const |
781 | { | 783 | { |
782 | const UInt32 kMinSize = 100; | 784 | const UInt32 kMinSize = 100; |
783 | if (unpackSize < kMinSize) | 785 | if (unpackSize < kMinSize) |
784 | unpackSize = kMinSize; | 786 | unpackSize = kMinSize; |
785 | return unpackSize * EncComplex; | 787 | return GetNumCommands_from_Size_and_Complexity(unpackSize, EncComplex); |
786 | } | 788 | } |
787 | 789 | ||
788 | UInt64 GeDecomprCommands(UInt64 packSize, UInt64 unpackSize) | 790 | UInt64 GetNumCommands_Dec(UInt64 packSize, UInt64 unpackSize) const |
789 | { | 791 | { |
790 | return (packSize * DecComplexCompr + unpackSize * DecComplexUnc); | 792 | return |
793 | GetNumCommands_from_Size_and_Complexity(packSize, DecComplexCompr) + | ||
794 | GetNumCommands_from_Size_and_Complexity(unpackSize, DecComplexUnc); | ||
791 | } | 795 | } |
792 | 796 | ||
793 | UInt64 GetCompressRating(UInt64 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size); | 797 | UInt64 GetRating_Enc(UInt64 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size) const; |
794 | UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations); | 798 | UInt64 GetRating_Dec(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations) const; |
795 | }; | 799 | }; |
796 | 800 | ||
797 | void CBenchProps::SetLzmaCompexity() | 801 | void CBenchProps::SetLzmaCompexity() |
@@ -802,11 +806,11 @@ void CBenchProps::SetLzmaCompexity() | |||
802 | LzmaRatingMode = true; | 806 | LzmaRatingMode = true; |
803 | } | 807 | } |
804 | 808 | ||
805 | UInt64 CBenchProps::GetCompressRating(UInt64 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size) | 809 | UInt64 CBenchProps::GetRating_Enc(UInt64 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size) const |
806 | { | 810 | { |
807 | if (dictSize < (1 << kBenchMinDicLogSize)) | 811 | if (dictSize < (1 << kBenchMinDicLogSize)) |
808 | dictSize = (1 << kBenchMinDicLogSize); | 812 | dictSize = (1 << kBenchMinDicLogSize); |
809 | UInt64 encComplex = EncComplex; | 813 | Int32 encComplex = EncComplex; |
810 | if (LzmaRatingMode) | 814 | if (LzmaRatingMode) |
811 | { | 815 | { |
812 | /* | 816 | /* |
@@ -822,13 +826,13 @@ UInt64 CBenchProps::GetCompressRating(UInt64 dictSize, UInt64 elapsedTime, UInt6 | |||
822 | const UInt32 t = GetLogSize_Sub(dictSize) - (kBenchMinDicLogSize << kSubBits); | 826 | const UInt32 t = GetLogSize_Sub(dictSize) - (kBenchMinDicLogSize << kSubBits); |
823 | encComplex = 870 + ((t * t * 5) >> (2 * kSubBits)); | 827 | encComplex = 870 + ((t * t * 5) >> (2 * kSubBits)); |
824 | } | 828 | } |
825 | const UInt64 numCommands = (UInt64)size * encComplex; | 829 | const UInt64 numCommands = GetNumCommands_from_Size_and_Complexity(size, encComplex); |
826 | return MyMultDiv64(numCommands, freq, elapsedTime); | 830 | return MyMultDiv64(numCommands, freq, elapsedTime); |
827 | } | 831 | } |
828 | 832 | ||
829 | UInt64 CBenchProps::GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations) | 833 | UInt64 CBenchProps::GetRating_Dec(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations) const |
830 | { | 834 | { |
831 | const UInt64 numCommands = (inSize * DecComplexCompr + outSize * DecComplexUnc) * numIterations; | 835 | const UInt64 numCommands = GetNumCommands_Dec(inSize, outSize) * numIterations; |
832 | return MyMultDiv64(numCommands, freq, elapsedTime); | 836 | return MyMultDiv64(numCommands, freq, elapsedTime); |
833 | } | 837 | } |
834 | 838 | ||
@@ -838,18 +842,18 @@ UInt64 CBenchInfo::GetRating_LzmaEnc(UInt64 dictSize) const | |||
838 | { | 842 | { |
839 | CBenchProps props; | 843 | CBenchProps props; |
840 | props.SetLzmaCompexity(); | 844 | props.SetLzmaCompexity(); |
841 | return props.GetCompressRating(dictSize, GlobalTime, GlobalFreq, UnpackSize * NumIterations); | 845 | return props.GetRating_Enc(dictSize, GlobalTime, GlobalFreq, UnpackSize * NumIterations); |
842 | } | 846 | } |
843 | 847 | ||
844 | UInt64 CBenchInfo::GetRating_LzmaDec() const | 848 | UInt64 CBenchInfo::GetRating_LzmaDec() const |
845 | { | 849 | { |
846 | CBenchProps props; | 850 | CBenchProps props; |
847 | props.SetLzmaCompexity(); | 851 | props.SetLzmaCompexity(); |
848 | return props.GetDecompressRating(GlobalTime, GlobalFreq, UnpackSize, PackSize, NumIterations); | 852 | return props.GetRating_Dec(GlobalTime, GlobalFreq, UnpackSize, PackSize, NumIterations); |
849 | } | 853 | } |
850 | 854 | ||
851 | 855 | ||
852 | #ifndef _7ZIP_ST | 856 | #ifndef Z7_ST |
853 | 857 | ||
854 | #define NUM_CPU_LEVELS_MAX 3 | 858 | #define NUM_CPU_LEVELS_MAX 3 |
855 | 859 | ||
@@ -988,15 +992,22 @@ struct CBenchSyncCommon | |||
988 | 992 | ||
989 | 993 | ||
990 | 994 | ||
995 | enum E_CheckCrcMode | ||
996 | { | ||
997 | k_CheckCrcMode_Never = 0, | ||
998 | k_CheckCrcMode_Always = 1, | ||
999 | k_CheckCrcMode_FirstPass = 2 | ||
1000 | }; | ||
1001 | |||
991 | class CEncoderInfo; | 1002 | class CEncoderInfo; |
992 | 1003 | ||
993 | class CEncoderInfo | 1004 | class CEncoderInfo Z7_final |
994 | { | 1005 | { |
995 | CLASS_NO_COPY(CEncoderInfo) | 1006 | Z7_CLASS_NO_COPY(CEncoderInfo) |
996 | 1007 | ||
997 | public: | 1008 | public: |
998 | 1009 | ||
999 | #ifndef _7ZIP_ST | 1010 | #ifndef Z7_ST |
1000 | NWindows::CThread thread[2]; | 1011 | NWindows::CThread thread[2]; |
1001 | NSynchronization::CManualResetEvent ReadyEvent; | 1012 | NSynchronization::CManualResetEvent ReadyEvent; |
1002 | UInt32 NumDecoderSubThreads; | 1013 | UInt32 NumDecoderSubThreads; |
@@ -1004,6 +1015,7 @@ public: | |||
1004 | UInt32 EncoderIndex; | 1015 | UInt32 EncoderIndex; |
1005 | UInt32 NumEncoderInternalThreads; | 1016 | UInt32 NumEncoderInternalThreads; |
1006 | CAffinityMode AffinityMode; | 1017 | CAffinityMode AffinityMode; |
1018 | bool IsGlobalMtMode; // if more than one benchmark encoder threads | ||
1007 | #endif | 1019 | #endif |
1008 | 1020 | ||
1009 | CMyComPtr<ICompressCoder> _encoder; | 1021 | CMyComPtr<ICompressCoder> _encoder; |
@@ -1024,14 +1036,17 @@ public: | |||
1024 | 1036 | ||
1025 | HRESULT Set_Key_and_IV(ICryptoProperties *cp) | 1037 | HRESULT Set_Key_and_IV(ICryptoProperties *cp) |
1026 | { | 1038 | { |
1027 | RINOK(cp->SetKey(_key, KeySize)); | 1039 | RINOK(cp->SetKey(_key, KeySize)) |
1028 | return cp->SetInitVector(_iv, sizeof(_iv)); | 1040 | return cp->SetInitVector(_iv, sizeof(_iv)); |
1029 | } | 1041 | } |
1030 | 1042 | ||
1031 | Byte _psw[16]; | 1043 | Byte _psw[16]; |
1032 | 1044 | ||
1033 | bool CheckCrc_Enc; | 1045 | bool CheckCrc_Enc; /* = 1, if we want to check packed data crcs after each pass |
1034 | bool CheckCrc_Dec; | 1046 | used for filter and usual coders */ |
1047 | bool UseRealData_Enc; /* = 1, if we want to use only original data for each pass | ||
1048 | used only for filter */ | ||
1049 | E_CheckCrcMode CheckCrcMode_Dec; | ||
1035 | 1050 | ||
1036 | struct CDecoderInfo | 1051 | struct CDecoderInfo |
1037 | { | 1052 | { |
@@ -1079,13 +1094,15 @@ public: | |||
1079 | HRESULT Decode(UInt32 decoderIndex); | 1094 | HRESULT Decode(UInt32 decoderIndex); |
1080 | 1095 | ||
1081 | CEncoderInfo(): | 1096 | CEncoderInfo(): |
1082 | #ifndef _7ZIP_ST | 1097 | #ifndef Z7_ST |
1083 | Common(NULL), | 1098 | Common(NULL), |
1099 | IsGlobalMtMode(true), | ||
1084 | #endif | 1100 | #endif |
1085 | Salt(0), | 1101 | Salt(0), |
1086 | KeySize(0), | 1102 | KeySize(0), |
1087 | CheckCrc_Enc(true), | 1103 | CheckCrc_Enc(true), |
1088 | CheckCrc_Dec(true), | 1104 | UseRealData_Enc(true), |
1105 | CheckCrcMode_Dec(k_CheckCrcMode_Always), | ||
1089 | outStreamSpec(NULL), | 1106 | outStreamSpec(NULL), |
1090 | callback(NULL), | 1107 | callback(NULL), |
1091 | printCallback(NULL), | 1108 | printCallback(NULL), |
@@ -1093,7 +1110,7 @@ public: | |||
1093 | propStreamSpec(NULL) | 1110 | propStreamSpec(NULL) |
1094 | {} | 1111 | {} |
1095 | 1112 | ||
1096 | #ifndef _7ZIP_ST | 1113 | #ifndef Z7_ST |
1097 | 1114 | ||
1098 | static THREAD_FUNC_DECL EncodeThreadFunction(void *param) | 1115 | static THREAD_FUNC_DECL EncodeThreadFunction(void *param) |
1099 | { | 1116 | { |
@@ -1115,7 +1132,7 @@ public: | |||
1115 | if (res != S_OK) | 1132 | if (res != S_OK) |
1116 | encoder->progressInfoSpec[0]->Status->SetResult(res); | 1133 | encoder->progressInfoSpec[0]->Status->SetResult(res); |
1117 | encoder->ReadyEvent.Set(); | 1134 | encoder->ReadyEvent.Set(); |
1118 | return 0; | 1135 | return THREAD_FUNC_RET_ZERO; |
1119 | } | 1136 | } |
1120 | 1137 | ||
1121 | static THREAD_FUNC_DECL DecodeThreadFunction(void *param) | 1138 | static THREAD_FUNC_DECL DecodeThreadFunction(void *param) |
@@ -1128,7 +1145,7 @@ public: | |||
1128 | 1145 | ||
1129 | CEncoderInfo *encoder = decoder->Encoder; | 1146 | CEncoderInfo *encoder = decoder->Encoder; |
1130 | encoder->Results[decoder->DecoderIndex] = encoder->Decode(decoder->DecoderIndex); | 1147 | encoder->Results[decoder->DecoderIndex] = encoder->Decode(decoder->DecoderIndex); |
1131 | return 0; | 1148 | return THREAD_FUNC_RET_ZERO; |
1132 | } | 1149 | } |
1133 | 1150 | ||
1134 | HRESULT CreateEncoderThread() | 1151 | HRESULT CreateEncoderThread() |
@@ -1184,17 +1201,30 @@ HRESULT CEncoderInfo::Generate() | |||
1184 | const COneMethodInfo &method = _method; | 1201 | const COneMethodInfo &method = _method; |
1185 | 1202 | ||
1186 | // we need extra space, if input data is already compressed | 1203 | // we need extra space, if input data is already compressed |
1187 | const size_t kCompressedBufferSize = GetBenchCompressedSize(kBufferSize); | 1204 | const size_t kCompressedBufferSize = _encoderFilter ? |
1205 | kBufferSize : | ||
1206 | GetBenchCompressedSize(kBufferSize); | ||
1188 | 1207 | ||
1189 | if (kCompressedBufferSize < kBufferSize) | 1208 | if (kCompressedBufferSize < kBufferSize) |
1190 | return E_FAIL; | 1209 | return E_FAIL; |
1191 | 1210 | ||
1192 | uncompressedDataPtr = fileData; | 1211 | uncompressedDataPtr = fileData; |
1193 | 1212 | if (fileData) | |
1194 | if (!fileData) | ||
1195 | { | 1213 | { |
1196 | ALLOC_WITH_HRESULT(&rg, kBufferSize); | 1214 | #if !defined(Z7_ST) |
1197 | 1215 | if (IsGlobalMtMode) | |
1216 | { | ||
1217 | /* we copy the data to local buffer of thread to eliminate | ||
1218 | using of shared buffer by different threads */ | ||
1219 | ALLOC_WITH_HRESULT(&rg, kBufferSize) | ||
1220 | memcpy((Byte *)rg, fileData, kBufferSize); | ||
1221 | uncompressedDataPtr = (const Byte *)rg; | ||
1222 | } | ||
1223 | #endif | ||
1224 | } | ||
1225 | else | ||
1226 | { | ||
1227 | ALLOC_WITH_HRESULT(&rg, kBufferSize) | ||
1198 | // DWORD ttt = GetTickCount(); | 1228 | // DWORD ttt = GetTickCount(); |
1199 | if (generateDictBits == 0) | 1229 | if (generateDictBits == 0) |
1200 | rg.GenerateSimpleRandom(Salt); | 1230 | rg.GenerateSimpleRandom(Salt); |
@@ -1211,12 +1241,6 @@ HRESULT CEncoderInfo::Generate() | |||
1211 | crc = CrcCalc((const Byte *)rg, rg.Size()); | 1241 | crc = CrcCalc((const Byte *)rg, rg.Size()); |
1212 | uncompressedDataPtr = (const Byte *)rg; | 1242 | uncompressedDataPtr = (const Byte *)rg; |
1213 | } | 1243 | } |
1214 | |||
1215 | if (_encoderFilter) | ||
1216 | { | ||
1217 | ALLOC_WITH_HRESULT(&rgCopy, kBufferSize); | ||
1218 | } | ||
1219 | |||
1220 | 1244 | ||
1221 | if (!outStream) | 1245 | if (!outStream) |
1222 | { | 1246 | { |
@@ -1226,6 +1250,15 @@ HRESULT CEncoderInfo::Generate() | |||
1226 | 1250 | ||
1227 | ALLOC_WITH_HRESULT(outStreamSpec, kCompressedBufferSize) | 1251 | ALLOC_WITH_HRESULT(outStreamSpec, kCompressedBufferSize) |
1228 | 1252 | ||
1253 | if (_encoderFilter) | ||
1254 | { | ||
1255 | /* we try to reduce the number of memcpy() in main encoding loop. | ||
1256 | so we copy data to temp buffers here */ | ||
1257 | ALLOC_WITH_HRESULT(&rgCopy, kBufferSize) | ||
1258 | memcpy((Byte *)*outStreamSpec, uncompressedDataPtr, kBufferSize); | ||
1259 | memcpy((Byte *)rgCopy, uncompressedDataPtr, kBufferSize); | ||
1260 | } | ||
1261 | |||
1229 | if (!propStream) | 1262 | if (!propStream) |
1230 | { | 1263 | { |
1231 | propStreamSpec = new CBufPtrSeqOutStream; // CBenchmarkOutStream; | 1264 | propStreamSpec = new CBufPtrSeqOutStream; // CBenchmarkOutStream; |
@@ -1251,7 +1284,7 @@ HRESULT CEncoderInfo::Generate() | |||
1251 | /* in posix new thread uses same affinity as parent thread, | 1284 | /* in posix new thread uses same affinity as parent thread, |
1252 | so we don't need to send affinity to coder in posix */ | 1285 | so we don't need to send affinity to coder in posix */ |
1253 | UInt64 affMask; | 1286 | UInt64 affMask; |
1254 | #if !defined(_7ZIP_ST) && defined(_WIN32) | 1287 | #if !defined(Z7_ST) && defined(_WIN32) |
1255 | { | 1288 | { |
1256 | CCpuSet cpuSet; | 1289 | CCpuSet cpuSet; |
1257 | affMask = AffinityMode.GetAffinityMask(EncoderIndex, &cpuSet); | 1290 | affMask = AffinityMode.GetAffinityMask(EncoderIndex, &cpuSet); |
@@ -1262,7 +1295,7 @@ HRESULT CEncoderInfo::Generate() | |||
1262 | // affMask <<= 3; // debug line: to test no affinity in coder; | 1295 | // affMask <<= 3; // debug line: to test no affinity in coder; |
1263 | // affMask = 0; | 1296 | // affMask = 0; |
1264 | 1297 | ||
1265 | RINOK(method.SetCoderProps_DSReduce_Aff(scp, &reduceSize, (affMask != 0 ? &affMask : NULL))); | 1298 | RINOK(method.SetCoderProps_DSReduce_Aff(scp, &reduceSize, (affMask != 0 ? &affMask : NULL))) |
1266 | } | 1299 | } |
1267 | else | 1300 | else |
1268 | { | 1301 | { |
@@ -1274,7 +1307,7 @@ HRESULT CEncoderInfo::Generate() | |||
1274 | coder.QueryInterface(IID_ICompressWriteCoderProperties, &writeCoderProps); | 1307 | coder.QueryInterface(IID_ICompressWriteCoderProperties, &writeCoderProps); |
1275 | if (writeCoderProps) | 1308 | if (writeCoderProps) |
1276 | { | 1309 | { |
1277 | RINOK(writeCoderProps->WriteCoderProperties(propStream)); | 1310 | RINOK(writeCoderProps->WriteCoderProperties(propStream)) |
1278 | } | 1311 | } |
1279 | 1312 | ||
1280 | { | 1313 | { |
@@ -1282,7 +1315,7 @@ HRESULT CEncoderInfo::Generate() | |||
1282 | coder.QueryInterface(IID_ICryptoSetPassword, &sp); | 1315 | coder.QueryInterface(IID_ICryptoSetPassword, &sp); |
1283 | if (sp) | 1316 | if (sp) |
1284 | { | 1317 | { |
1285 | RINOK(sp->CryptoSetPassword(_psw, sizeof(_psw))); | 1318 | RINOK(sp->CryptoSetPassword(_psw, sizeof(_psw))) |
1286 | 1319 | ||
1287 | // we must call encoding one time to calculate password key for key cache. | 1320 | // we must call encoding one time to calculate password key for key cache. |
1288 | // it must be after WriteCoderProperties! | 1321 | // it must be after WriteCoderProperties! |
@@ -1304,7 +1337,7 @@ HRESULT CEncoderInfo::Generate() | |||
1304 | CMyComPtr<ISequentialOutStream> crcStream = crcStreamSpec; | 1337 | CMyComPtr<ISequentialOutStream> crcStream = crcStreamSpec; |
1305 | crcStreamSpec->Init(); | 1338 | crcStreamSpec->Init(); |
1306 | 1339 | ||
1307 | RINOK(_encoder->Code(inStream, crcStream, 0, 0, NULL)); | 1340 | RINOK(_encoder->Code(inStream, crcStream, NULL, NULL, NULL)) |
1308 | } | 1341 | } |
1309 | } | 1342 | } |
1310 | } | 1343 | } |
@@ -1314,19 +1347,22 @@ HRESULT CEncoderInfo::Generate() | |||
1314 | } | 1347 | } |
1315 | 1348 | ||
1316 | 1349 | ||
1317 | static void My_FilterBench(ICompressFilter *filter, Byte *data, size_t size) | 1350 | static void My_FilterBench(ICompressFilter *filter, Byte *data, size_t size, UInt32 *crc) |
1318 | { | 1351 | { |
1319 | while (size != 0) | 1352 | while (size != 0) |
1320 | { | 1353 | { |
1321 | UInt32 cur = (UInt32)1 << 31; | 1354 | UInt32 cur = crc ? 1 << 17 : 1 << 24; |
1322 | if (cur > size) | 1355 | if (cur > size) |
1323 | cur = (UInt32)size; | 1356 | cur = (UInt32)size; |
1324 | UInt32 processed = filter->Filter(data, cur); | 1357 | UInt32 processed = filter->Filter(data, cur); |
1325 | data += processed; | 1358 | /* if (processed > size) (in AES filter), we must fill last block with zeros. |
1326 | // if (processed > size) (in AES filter), we must fill last block with zeros. | 1359 | but it is not important for benchmark. So we just copy that data without filtering. |
1327 | // but it is not important for benchmark. So we just copy that data without filtering. | 1360 | if (processed == 0) then filter can't process more */ |
1328 | if (processed > size || processed == 0) | 1361 | if (processed > size || processed == 0) |
1329 | break; | 1362 | processed = (UInt32)size; |
1363 | if (crc) | ||
1364 | *crc = CrcUpdate(*crc, data, processed); | ||
1365 | data += processed; | ||
1330 | size -= processed; | 1366 | size -= processed; |
1331 | } | 1367 | } |
1332 | } | 1368 | } |
@@ -1336,11 +1372,11 @@ HRESULT CEncoderInfo::Encode() | |||
1336 | { | 1372 | { |
1337 | // printf("\nCEncoderInfo::Generate\n"); | 1373 | // printf("\nCEncoderInfo::Generate\n"); |
1338 | 1374 | ||
1339 | RINOK(Generate()); | 1375 | RINOK(Generate()) |
1340 | 1376 | ||
1341 | // printf("\n2222\n"); | 1377 | // printf("\n2222\n"); |
1342 | 1378 | ||
1343 | #ifndef _7ZIP_ST | 1379 | #ifndef Z7_ST |
1344 | if (Common) | 1380 | if (Common) |
1345 | { | 1381 | { |
1346 | Results[0] = S_OK; | 1382 | Results[0] = S_OK; |
@@ -1375,7 +1411,7 @@ HRESULT CEncoderInfo::Encode() | |||
1375 | 1411 | ||
1376 | if (cp) | 1412 | if (cp) |
1377 | { | 1413 | { |
1378 | RINOK(Set_Key_and_IV(cp)); | 1414 | RINOK(Set_Key_and_IV(cp)) |
1379 | } | 1415 | } |
1380 | 1416 | ||
1381 | compressedSize = 0; | 1417 | compressedSize = 0; |
@@ -1384,20 +1420,32 @@ HRESULT CEncoderInfo::Encode() | |||
1384 | 1420 | ||
1385 | // CBenchmarkOutStream *outStreamSpec = this->outStreamSpec; | 1421 | // CBenchmarkOutStream *outStreamSpec = this->outStreamSpec; |
1386 | UInt64 prev = 0; | 1422 | UInt64 prev = 0; |
1387 | const UInt32 mask = (CheckCrc_Enc ? 0 : 0xFFF); | 1423 | |
1388 | bool useCrc = (mask < NumIterations); | 1424 | const UInt32 mask = (CheckCrc_Enc ? 0 : 0xFFFF); |
1425 | const bool useCrc = (mask < NumIterations); | ||
1389 | bool crcPrev_defined = false; | 1426 | bool crcPrev_defined = false; |
1390 | UInt32 crcPrev = 0; | 1427 | UInt32 crcPrev = 0; |
1391 | UInt64 i = NumIterations; | 1428 | |
1429 | bool useRealData_Enc = UseRealData_Enc; | ||
1430 | bool data_Was_Changed = false; | ||
1431 | if (useRealData_Enc) | ||
1432 | { | ||
1433 | /* we want memcpy() for each iteration including first iteration. | ||
1434 | So results will be equal for different number of iterations */ | ||
1435 | data_Was_Changed = true; | ||
1436 | } | ||
1437 | |||
1438 | const UInt64 numIterations = NumIterations; | ||
1439 | UInt64 i = numIterations; | ||
1392 | // printCallback->NewLine(); | 1440 | // printCallback->NewLine(); |
1393 | 1441 | ||
1394 | while (i != 0) | 1442 | while (i != 0) |
1395 | { | 1443 | { |
1396 | i--; | 1444 | i--; |
1397 | if (printCallback && bi.UnpackSize - prev >= (1 << 24)) | 1445 | if (printCallback && bi.UnpackSize - prev >= (1 << 26)) |
1398 | { | 1446 | { |
1399 | RINOK(printCallback->CheckBreak()); | ||
1400 | prev = bi.UnpackSize; | 1447 | prev = bi.UnpackSize; |
1448 | RINOK(printCallback->CheckBreak()) | ||
1401 | } | 1449 | } |
1402 | 1450 | ||
1403 | /* | 1451 | /* |
@@ -1411,21 +1459,25 @@ HRESULT CEncoderInfo::Encode() | |||
1411 | 1459 | ||
1412 | if (_encoderFilter) | 1460 | if (_encoderFilter) |
1413 | { | 1461 | { |
1414 | // if (needRealData) | 1462 | Byte *filterData = rgCopy; |
1415 | memcpy((Byte *)*outStreamSpec, uncompressedDataPtr, kBufferSize); | 1463 | if (i == numIterations - 1 || calcCrc || useRealData_Enc) |
1464 | { | ||
1465 | filterData = (Byte *)*outStreamSpec; | ||
1466 | if (data_Was_Changed) | ||
1467 | memcpy(filterData, uncompressedDataPtr, kBufferSize); | ||
1468 | data_Was_Changed = true; | ||
1469 | } | ||
1416 | _encoderFilter->Init(); | 1470 | _encoderFilter->Init(); |
1417 | My_FilterBench(_encoderFilter, (Byte *)*outStreamSpec, kBufferSize); | ||
1418 | if (calcCrc) | 1471 | if (calcCrc) |
1419 | { | ||
1420 | outStreamSpec->InitCrc(); | 1472 | outStreamSpec->InitCrc(); |
1421 | outStreamSpec->Calc((Byte *)*outStreamSpec, kBufferSize); | 1473 | My_FilterBench(_encoderFilter, filterData, kBufferSize, |
1422 | } | 1474 | calcCrc ? &outStreamSpec->Crc : NULL); |
1423 | } | 1475 | } |
1424 | else | 1476 | else |
1425 | { | 1477 | { |
1426 | outStreamSpec->Init(true, calcCrc); // write real data for speed consistency at any number of iterations | 1478 | outStreamSpec->Init(true, calcCrc); // write real data for speed consistency at any number of iterations |
1427 | inStreamSpec->Init(uncompressedDataPtr, kBufferSize); | 1479 | inStreamSpec->Init(uncompressedDataPtr, kBufferSize); |
1428 | RINOK(_encoder->Code(inStream, outStream, NULL, NULL, progressInfo[0])); | 1480 | RINOK(_encoder->Code(inStream, outStream, NULL, NULL, progressInfo[0])) |
1429 | if (!inStreamSpec->WasFinished()) | 1481 | if (!inStreamSpec->WasFinished()) |
1430 | return E_FAIL; | 1482 | return E_FAIL; |
1431 | if (compressedSize != outStreamSpec->Pos) | 1483 | if (compressedSize != outStreamSpec->Pos) |
@@ -1461,7 +1513,7 @@ HRESULT CEncoderInfo::Encode() | |||
1461 | info.PackSize = compressedSize; | 1513 | info.PackSize = compressedSize; |
1462 | // printf("\n%7d\n", encoder.compressedSize); | 1514 | // printf("\n%7d\n", encoder.compressedSize); |
1463 | 1515 | ||
1464 | RINOK(callback->SetEncodeResult(info, true)); | 1516 | RINOK(callback->SetEncodeResult(info, true)) |
1465 | printCallback->NewLine(); | 1517 | printCallback->NewLine(); |
1466 | } | 1518 | } |
1467 | */ | 1519 | */ |
@@ -1501,13 +1553,13 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1501 | pi->BenchInfo.UnpackSize = 0; | 1553 | pi->BenchInfo.UnpackSize = 0; |
1502 | pi->BenchInfo.PackSize = 0; | 1554 | pi->BenchInfo.PackSize = 0; |
1503 | 1555 | ||
1504 | #ifndef _7ZIP_ST | 1556 | #ifndef Z7_ST |
1505 | { | 1557 | { |
1506 | CMyComPtr<ICompressSetCoderMt> setCoderMt; | 1558 | CMyComPtr<ICompressSetCoderMt> setCoderMt; |
1507 | coder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt); | 1559 | coder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt); |
1508 | if (setCoderMt) | 1560 | if (setCoderMt) |
1509 | { | 1561 | { |
1510 | RINOK(setCoderMt->SetNumberOfThreads(NumDecoderSubThreads)); | 1562 | RINOK(setCoderMt->SetNumberOfThreads(NumDecoderSubThreads)) |
1511 | } | 1563 | } |
1512 | } | 1564 | } |
1513 | #endif | 1565 | #endif |
@@ -1517,7 +1569,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1517 | if (scp) | 1569 | if (scp) |
1518 | { | 1570 | { |
1519 | const UInt64 reduceSize = _uncompressedDataSize; | 1571 | const UInt64 reduceSize = _uncompressedDataSize; |
1520 | RINOK(_method.SetCoderProps(scp, &reduceSize)); | 1572 | RINOK(_method.SetCoderProps(scp, &reduceSize)) |
1521 | } | 1573 | } |
1522 | 1574 | ||
1523 | CMyComPtr<ICryptoProperties> cp; | 1575 | CMyComPtr<ICryptoProperties> cp; |
@@ -1528,7 +1580,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1528 | RINOK(setDecProps->SetDecoderProperties2( | 1580 | RINOK(setDecProps->SetDecoderProperties2( |
1529 | /* (const Byte *)*propStreamSpec, */ | 1581 | /* (const Byte *)*propStreamSpec, */ |
1530 | propsData, | 1582 | propsData, |
1531 | (UInt32)propStreamSpec->GetPos())); | 1583 | (UInt32)propStreamSpec->GetPos())) |
1532 | } | 1584 | } |
1533 | 1585 | ||
1534 | { | 1586 | { |
@@ -1536,7 +1588,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1536 | coder.QueryInterface(IID_ICryptoSetPassword, &sp); | 1588 | coder.QueryInterface(IID_ICryptoSetPassword, &sp); |
1537 | if (sp) | 1589 | if (sp) |
1538 | { | 1590 | { |
1539 | RINOK(sp->CryptoSetPassword(_psw, sizeof(_psw))); | 1591 | RINOK(sp->CryptoSetPassword(_psw, sizeof(_psw))) |
1540 | } | 1592 | } |
1541 | } | 1593 | } |
1542 | 1594 | ||
@@ -1544,7 +1596,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1544 | 1596 | ||
1545 | if (cp) | 1597 | if (cp) |
1546 | { | 1598 | { |
1547 | RINOK(Set_Key_and_IV(cp)); | 1599 | RINOK(Set_Key_and_IV(cp)) |
1548 | } | 1600 | } |
1549 | 1601 | ||
1550 | CMyComPtr<ICompressSetFinishMode> setFinishMode; | 1602 | CMyComPtr<ICompressSetFinishMode> setFinishMode; |
@@ -1559,32 +1611,38 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1559 | decoder->QueryInterface(IID_ICompressSetFinishMode, (void **)&setFinishMode); | 1611 | decoder->QueryInterface(IID_ICompressSetFinishMode, (void **)&setFinishMode); |
1560 | } | 1612 | } |
1561 | 1613 | ||
1562 | const UInt64 numIterations = this->NumIterations; | 1614 | const UInt64 numIterations = NumIterations; |
1563 | const UInt32 mask = (CheckCrc_Dec ? 0 : 0xFFF); | 1615 | const E_CheckCrcMode checkCrcMode = CheckCrcMode_Dec; |
1564 | 1616 | ||
1565 | for (UInt64 i = 0; i < numIterations; i++) | 1617 | for (UInt64 i = 0; i < numIterations; i++) |
1566 | { | 1618 | { |
1567 | if (printCallback && pi->BenchInfo.UnpackSize - prev >= (1 << 24)) | 1619 | if (printCallback && pi->BenchInfo.UnpackSize - prev >= (1 << 26)) |
1568 | { | 1620 | { |
1569 | RINOK(printCallback->CheckBreak()); | 1621 | RINOK(printCallback->CheckBreak()) |
1570 | prev = pi->BenchInfo.UnpackSize; | 1622 | prev = pi->BenchInfo.UnpackSize; |
1571 | } | 1623 | } |
1572 | 1624 | ||
1573 | const UInt64 outSize = kBufferSize; | 1625 | const UInt64 outSize = kBufferSize; |
1574 | bool calcCrc = false; | 1626 | bool calcCrc = (checkCrcMode != k_CheckCrcMode_Never); |
1575 | if (((UInt32)i & mask) == 0) | 1627 | |
1576 | calcCrc = true; | ||
1577 | crcOutStreamSpec->Init(); | 1628 | crcOutStreamSpec->Init(); |
1578 | 1629 | ||
1579 | if (_decoderFilter) | 1630 | if (_decoderFilter) |
1580 | { | 1631 | { |
1581 | if (calcCrc) // for pure filter speed test without multi-iteration consistency | 1632 | Byte *filterData = (Byte *)*outStreamSpec; |
1582 | // if (needRealData) | ||
1583 | memcpy((Byte *)rgCopy, (const Byte *)*outStreamSpec, compressedSize); | ||
1584 | _decoderFilter->Init(); | ||
1585 | My_FilterBench(_decoderFilter, (Byte *)rgCopy, compressedSize); | ||
1586 | if (calcCrc) | 1633 | if (calcCrc) |
1587 | crcOutStreamSpec->Calc((const Byte *)rgCopy, compressedSize); | 1634 | { |
1635 | calcCrc = (i == 0); | ||
1636 | if (checkCrcMode == k_CheckCrcMode_Always) | ||
1637 | { | ||
1638 | calcCrc = true; | ||
1639 | memcpy((Byte *)rgCopy, (const Byte *)*outStreamSpec, compressedSize); | ||
1640 | filterData = rgCopy; | ||
1641 | } | ||
1642 | } | ||
1643 | _decoderFilter->Init(); | ||
1644 | My_FilterBench(_decoderFilter, filterData, compressedSize, | ||
1645 | calcCrc ? &crcOutStreamSpec->Crc : NULL); | ||
1588 | } | 1646 | } |
1589 | else | 1647 | else |
1590 | { | 1648 | { |
@@ -1593,10 +1651,10 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1593 | 1651 | ||
1594 | if (setFinishMode) | 1652 | if (setFinishMode) |
1595 | { | 1653 | { |
1596 | RINOK(setFinishMode->SetFinishMode(BoolToUInt(true))); | 1654 | RINOK(setFinishMode->SetFinishMode(BoolToUInt(true))) |
1597 | } | 1655 | } |
1598 | 1656 | ||
1599 | RINOK(decoder->Code(inStream, crcOutStream, 0, &outSize, progressInfo[decoderIndex])); | 1657 | RINOK(decoder->Code(inStream, crcOutStream, NULL, &outSize, progressInfo[decoderIndex])) |
1600 | 1658 | ||
1601 | if (setFinishMode) | 1659 | if (setFinishMode) |
1602 | { | 1660 | { |
@@ -1609,7 +1667,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) | |||
1609 | if (getInStreamProcessedSize) | 1667 | if (getInStreamProcessedSize) |
1610 | { | 1668 | { |
1611 | UInt64 processed; | 1669 | UInt64 processed; |
1612 | RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&processed)); | 1670 | RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&processed)) |
1613 | if (processed != compressedSize) | 1671 | if (processed != compressedSize) |
1614 | return S_FALSE; | 1672 | return S_FALSE; |
1615 | } | 1673 | } |
@@ -1652,7 +1710,7 @@ static UInt64 GetNumIterations(UInt64 numCommands, UInt64 complexInCommands) | |||
1652 | 1710 | ||
1653 | 1711 | ||
1654 | 1712 | ||
1655 | #ifndef _7ZIP_ST | 1713 | #ifndef Z7_ST |
1656 | 1714 | ||
1657 | // ---------- CBenchThreadsFlusher ---------- | 1715 | // ---------- CBenchThreadsFlusher ---------- |
1658 | 1716 | ||
@@ -1696,7 +1754,7 @@ WRes CBenchThreadsFlusher::StartAndWait(bool exitMode) | |||
1696 | return res; | 1754 | return res; |
1697 | } | 1755 | } |
1698 | 1756 | ||
1699 | #endif // _7ZIP_ST | 1757 | #endif // Z7_ST |
1700 | 1758 | ||
1701 | 1759 | ||
1702 | 1760 | ||
@@ -1714,7 +1772,7 @@ static void SetPseudoRand(Byte *data, size_t size, UInt32 startValue) | |||
1714 | static HRESULT MethodBench( | 1772 | static HRESULT MethodBench( |
1715 | DECL_EXTERNAL_CODECS_LOC_VARS | 1773 | DECL_EXTERNAL_CODECS_LOC_VARS |
1716 | UInt64 complexInCommands, | 1774 | UInt64 complexInCommands, |
1717 | #ifndef _7ZIP_ST | 1775 | #ifndef Z7_ST |
1718 | bool oldLzmaBenchMode, | 1776 | bool oldLzmaBenchMode, |
1719 | UInt32 numThreads, | 1777 | UInt32 numThreads, |
1720 | const CAffinityMode *affinityMode, | 1778 | const CAffinityMode *affinityMode, |
@@ -1731,10 +1789,11 @@ static HRESULT MethodBench( | |||
1731 | COneMethodInfo method = method2; | 1789 | COneMethodInfo method = method2; |
1732 | UInt64 methodId; | 1790 | UInt64 methodId; |
1733 | UInt32 numStreams; | 1791 | UInt32 numStreams; |
1792 | bool isFilter; | ||
1734 | const int codecIndex = FindMethod_Index( | 1793 | const int codecIndex = FindMethod_Index( |
1735 | EXTERNAL_CODECS_LOC_VARS | 1794 | EXTERNAL_CODECS_LOC_VARS |
1736 | method.MethodName, true, | 1795 | method.MethodName, true, |
1737 | methodId, numStreams); | 1796 | methodId, numStreams, isFilter); |
1738 | if (codecIndex < 0) | 1797 | if (codecIndex < 0) |
1739 | return E_NOTIMPL; | 1798 | return E_NOTIMPL; |
1740 | if (numStreams != 1) | 1799 | if (numStreams != 1) |
@@ -1743,7 +1802,7 @@ static HRESULT MethodBench( | |||
1743 | UInt32 numEncoderThreads = 1; | 1802 | UInt32 numEncoderThreads = 1; |
1744 | UInt32 numSubDecoderThreads = 1; | 1803 | UInt32 numSubDecoderThreads = 1; |
1745 | 1804 | ||
1746 | #ifndef _7ZIP_ST | 1805 | #ifndef Z7_ST |
1747 | numEncoderThreads = numThreads; | 1806 | numEncoderThreads = numThreads; |
1748 | 1807 | ||
1749 | if (oldLzmaBenchMode) | 1808 | if (oldLzmaBenchMode) |
@@ -1759,7 +1818,7 @@ static HRESULT MethodBench( | |||
1759 | } | 1818 | } |
1760 | } | 1819 | } |
1761 | 1820 | ||
1762 | bool mtEncMode = (numEncoderThreads > 1) || affinityMode->NeedAffinity(); | 1821 | const bool mtEncMode = (numEncoderThreads > 1) || affinityMode->NeedAffinity(); |
1763 | 1822 | ||
1764 | #endif | 1823 | #endif |
1765 | 1824 | ||
@@ -1771,10 +1830,10 @@ static HRESULT MethodBench( | |||
1771 | for (i = 0; i < numEncoderThreads; i++) | 1830 | for (i = 0; i < numEncoderThreads; i++) |
1772 | { | 1831 | { |
1773 | CEncoderInfo &encoder = encoders[i]; | 1832 | CEncoderInfo &encoder = encoders[i]; |
1774 | encoder.callback = (i == 0) ? callback : 0; | 1833 | encoder.callback = (i == 0) ? callback : NULL; |
1775 | encoder.printCallback = printCallback; | 1834 | encoder.printCallback = printCallback; |
1776 | 1835 | ||
1777 | #ifndef _7ZIP_ST | 1836 | #ifndef Z7_ST |
1778 | encoder.EncoderIndex = i; | 1837 | encoder.EncoderIndex = i; |
1779 | encoder.NumEncoderInternalThreads = numSubDecoderThreads; | 1838 | encoder.NumEncoderInternalThreads = numSubDecoderThreads; |
1780 | encoder.AffinityMode = *affinityMode; | 1839 | encoder.AffinityMode = *affinityMode; |
@@ -1794,15 +1853,12 @@ static HRESULT MethodBench( | |||
1794 | 1853 | ||
1795 | { | 1854 | { |
1796 | CCreatedCoder cod; | 1855 | CCreatedCoder cod; |
1797 | RINOK(CreateCoder_Index(EXTERNAL_CODECS_LOC_VARS (unsigned)codecIndex, true, encoder._encoderFilter, cod)); | 1856 | RINOK(CreateCoder_Index(EXTERNAL_CODECS_LOC_VARS (unsigned)codecIndex, true, encoder._encoderFilter, cod)) |
1798 | encoder._encoder = cod.Coder; | 1857 | encoder._encoder = cod.Coder; |
1799 | if (!encoder._encoder && !encoder._encoderFilter) | 1858 | if (!encoder._encoder && !encoder._encoderFilter) |
1800 | return E_NOTIMPL; | 1859 | return E_NOTIMPL; |
1801 | } | 1860 | } |
1802 | 1861 | ||
1803 | encoder.CheckCrc_Enc = (benchProps->EncComplex) > 30; | ||
1804 | encoder.CheckCrc_Dec = (benchProps->DecComplexCompr + benchProps->DecComplexUnc) > 30; | ||
1805 | |||
1806 | SetPseudoRand(encoder._iv, sizeof(encoder._iv), 17); | 1862 | SetPseudoRand(encoder._iv, sizeof(encoder._iv), 17); |
1807 | SetPseudoRand(encoder._key, sizeof(encoder._key), 51); | 1863 | SetPseudoRand(encoder._key, sizeof(encoder._key), 51); |
1808 | SetPseudoRand(encoder._psw, sizeof(encoder._psw), 123); | 1864 | SetPseudoRand(encoder._psw, sizeof(encoder._psw), 123); |
@@ -1811,11 +1867,27 @@ static HRESULT MethodBench( | |||
1811 | { | 1867 | { |
1812 | CCreatedCoder cod; | 1868 | CCreatedCoder cod; |
1813 | CMyComPtr<ICompressCoder> &decoder = encoder._decoders[j]; | 1869 | CMyComPtr<ICompressCoder> &decoder = encoder._decoders[j]; |
1814 | RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS methodId, false, encoder._decoderFilter, cod)); | 1870 | RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS methodId, false, encoder._decoderFilter, cod)) |
1815 | decoder = cod.Coder; | 1871 | decoder = cod.Coder; |
1816 | if (!encoder._decoderFilter && !decoder) | 1872 | if (!encoder._decoderFilter && !decoder) |
1817 | return E_NOTIMPL; | 1873 | return E_NOTIMPL; |
1818 | } | 1874 | } |
1875 | |||
1876 | encoder.UseRealData_Enc = | ||
1877 | encoder.CheckCrc_Enc = (benchProps->EncComplex) > 30; | ||
1878 | |||
1879 | encoder.CheckCrcMode_Dec = k_CheckCrcMode_Always; | ||
1880 | if (benchProps->DecComplexCompr + | ||
1881 | benchProps->DecComplexUnc <= 30) | ||
1882 | encoder.CheckCrcMode_Dec = | ||
1883 | k_CheckCrcMode_FirstPass; // for filters | ||
1884 | // k_CheckCrcMode_Never; // for debug | ||
1885 | // k_CheckCrcMode_Always; // for debug | ||
1886 | if (fileData) | ||
1887 | { | ||
1888 | encoder.UseRealData_Enc = true; | ||
1889 | encoder.CheckCrcMode_Dec = k_CheckCrcMode_Always; | ||
1890 | } | ||
1819 | } | 1891 | } |
1820 | 1892 | ||
1821 | UInt32 crc = 0; | 1893 | UInt32 crc = 0; |
@@ -1837,7 +1909,7 @@ static HRESULT MethodBench( | |||
1837 | status.Res = S_OK; | 1909 | status.Res = S_OK; |
1838 | status.EncodeMode = true; | 1910 | status.EncodeMode = true; |
1839 | 1911 | ||
1840 | #ifndef _7ZIP_ST | 1912 | #ifndef Z7_ST |
1841 | CBenchThreadsFlusher encoderFlusher; | 1913 | CBenchThreadsFlusher encoderFlusher; |
1842 | if (mtEncMode) | 1914 | if (mtEncMode) |
1843 | { | 1915 | { |
@@ -1853,7 +1925,7 @@ static HRESULT MethodBench( | |||
1853 | for (i = 0; i < numEncoderThreads; i++) | 1925 | for (i = 0; i < numEncoderThreads; i++) |
1854 | { | 1926 | { |
1855 | CEncoderInfo &encoder = encoders[i]; | 1927 | CEncoderInfo &encoder = encoders[i]; |
1856 | encoder.NumIterations = GetNumIterations(benchProps->GeComprCommands(uncompressedDataSize), complexInCommands); | 1928 | encoder.NumIterations = GetNumIterations(benchProps->GetNumCommands_Enc(uncompressedDataSize), complexInCommands); |
1857 | // encoder.NumIterations = 3; | 1929 | // encoder.NumIterations = 3; |
1858 | encoder.Salt = g_CrcTable[i & 0xFF]; | 1930 | encoder.Salt = g_CrcTable[i & 0xFF]; |
1859 | encoder.Salt ^= (g_CrcTable[(i >> 8) & 0xFF] << 3); | 1931 | encoder.Salt ^= (g_CrcTable[(i >> 8) & 0xFF] << 3); |
@@ -1877,7 +1949,7 @@ static HRESULT MethodBench( | |||
1877 | bpi->BenchInfo.NumIterations = numEncoderThreads; | 1949 | bpi->BenchInfo.NumIterations = numEncoderThreads; |
1878 | } | 1950 | } |
1879 | 1951 | ||
1880 | #ifndef _7ZIP_ST | 1952 | #ifndef Z7_ST |
1881 | if (mtEncMode) | 1953 | if (mtEncMode) |
1882 | { | 1954 | { |
1883 | #ifdef USE_ALLOCA | 1955 | #ifdef USE_ALLOCA |
@@ -1885,6 +1957,7 @@ static HRESULT MethodBench( | |||
1885 | #endif | 1957 | #endif |
1886 | 1958 | ||
1887 | encoder.Common = &encoderFlusher.Common; | 1959 | encoder.Common = &encoderFlusher.Common; |
1960 | encoder.IsGlobalMtMode = numEncoderThreads > 1; | ||
1888 | RINOK(encoder.CreateEncoderThread()) | 1961 | RINOK(encoder.CreateEncoderThread()) |
1889 | } | 1962 | } |
1890 | #endif | 1963 | #endif |
@@ -1892,35 +1965,35 @@ static HRESULT MethodBench( | |||
1892 | 1965 | ||
1893 | if (printCallback) | 1966 | if (printCallback) |
1894 | { | 1967 | { |
1895 | RINOK(printCallback->CheckBreak()); | 1968 | RINOK(printCallback->CheckBreak()) |
1896 | } | 1969 | } |
1897 | 1970 | ||
1898 | #ifndef _7ZIP_ST | 1971 | #ifndef Z7_ST |
1899 | if (mtEncMode) | 1972 | if (mtEncMode) |
1900 | { | 1973 | { |
1901 | for (i = 0; i < numEncoderThreads; i++) | 1974 | for (i = 0; i < numEncoderThreads; i++) |
1902 | { | 1975 | { |
1903 | CEncoderInfo &encoder = encoders[i]; | 1976 | CEncoderInfo &encoder = encoders[i]; |
1904 | WRes wres = encoder.ReadyEvent.Lock(); | 1977 | const WRes wres = encoder.ReadyEvent.Lock(); |
1905 | if (wres != 0) | 1978 | if (wres != 0) |
1906 | return HRESULT_FROM_WIN32(wres); | 1979 | return HRESULT_FROM_WIN32(wres); |
1907 | RINOK(encoder.Results[0]); | 1980 | RINOK(encoder.Results[0]) |
1908 | } | 1981 | } |
1909 | 1982 | ||
1910 | CBenchProgressInfo *bpi = encoders[0].progressInfoSpec[0]; | 1983 | CBenchProgressInfo *bpi = encoders[0].progressInfoSpec[0]; |
1911 | bpi->SetStartTime(); | 1984 | bpi->SetStartTime(); |
1912 | 1985 | ||
1913 | WRes wres = encoderFlusher.StartAndWait(); | 1986 | const WRes wres = encoderFlusher.StartAndWait(); |
1914 | if (status.Res == 0 && wres != 0) | 1987 | if (status.Res == 0 && wres != 0) |
1915 | return HRESULT_FROM_WIN32(wres); | 1988 | return HRESULT_FROM_WIN32(wres); |
1916 | } | 1989 | } |
1917 | else | 1990 | else |
1918 | #endif | 1991 | #endif |
1919 | { | 1992 | { |
1920 | RINOK(encoders[0].Encode()); | 1993 | RINOK(encoders[0].Encode()) |
1921 | } | 1994 | } |
1922 | 1995 | ||
1923 | RINOK(status.Res); | 1996 | RINOK(status.Res) |
1924 | 1997 | ||
1925 | CBenchInfo info; | 1998 | CBenchInfo info; |
1926 | 1999 | ||
@@ -1931,13 +2004,13 @@ static HRESULT MethodBench( | |||
1931 | 2004 | ||
1932 | for (i = 0; i < numEncoderThreads; i++) | 2005 | for (i = 0; i < numEncoderThreads; i++) |
1933 | { | 2006 | { |
1934 | CEncoderInfo &encoder = encoders[i]; | 2007 | const CEncoderInfo &encoder = encoders[i]; |
1935 | info.UnpackSize += encoder.kBufferSize; | 2008 | info.UnpackSize += encoder.kBufferSize; |
1936 | info.PackSize += encoder.compressedSize; | 2009 | info.PackSize += encoder.compressedSize; |
1937 | // printf("\n%7d\n", encoder.compressedSize); | 2010 | // printf("\n%7d\n", encoder.compressedSize); |
1938 | } | 2011 | } |
1939 | 2012 | ||
1940 | RINOK(callback->SetEncodeResult(info, true)); | 2013 | RINOK(callback->SetEncodeResult(info, true)) |
1941 | 2014 | ||
1942 | 2015 | ||
1943 | 2016 | ||
@@ -1948,7 +2021,7 @@ static HRESULT MethodBench( | |||
1948 | status.EncodeMode = false; | 2021 | status.EncodeMode = false; |
1949 | 2022 | ||
1950 | const UInt32 numDecoderThreads = numEncoderThreads * numSubDecoderThreads; | 2023 | const UInt32 numDecoderThreads = numEncoderThreads * numSubDecoderThreads; |
1951 | #ifndef _7ZIP_ST | 2024 | #ifndef Z7_ST |
1952 | const bool mtDecoderMode = (numDecoderThreads > 1) || affinityMode->NeedAffinity(); | 2025 | const bool mtDecoderMode = (numDecoderThreads > 1) || affinityMode->NeedAffinity(); |
1953 | #endif | 2026 | #endif |
1954 | 2027 | ||
@@ -1957,7 +2030,7 @@ static HRESULT MethodBench( | |||
1957 | CEncoderInfo &encoder = encoders[i]; | 2030 | CEncoderInfo &encoder = encoders[i]; |
1958 | 2031 | ||
1959 | /* | 2032 | /* |
1960 | #ifndef _7ZIP_ST | 2033 | #ifndef Z7_ST |
1961 | // encoder.affinityMode = *affinityMode; | 2034 | // encoder.affinityMode = *affinityMode; |
1962 | if (encoder.NumEncoderInternalThreads != 1) | 2035 | if (encoder.NumEncoderInternalThreads != 1) |
1963 | encoder.AffinityMode.DivideNum = encoder.NumEncoderInternalThreads; | 2036 | encoder.AffinityMode.DivideNum = encoder.NumEncoderInternalThreads; |
@@ -1967,7 +2040,11 @@ static HRESULT MethodBench( | |||
1967 | 2040 | ||
1968 | if (i == 0) | 2041 | if (i == 0) |
1969 | { | 2042 | { |
1970 | encoder.NumIterations = GetNumIterations(benchProps->GeDecomprCommands(encoder.compressedSize, encoder.kBufferSize), complexInCommands); | 2043 | encoder.NumIterations = GetNumIterations( |
2044 | benchProps->GetNumCommands_Dec( | ||
2045 | encoder.compressedSize, | ||
2046 | encoder.kBufferSize), | ||
2047 | complexInCommands); | ||
1971 | CBenchProgressInfo *bpi = encoder.progressInfoSpec[0]; | 2048 | CBenchProgressInfo *bpi = encoder.progressInfoSpec[0]; |
1972 | bpi->Callback = callback; | 2049 | bpi->Callback = callback; |
1973 | bpi->BenchInfo.NumIterations = numDecoderThreads; | 2050 | bpi->BenchInfo.NumIterations = numDecoderThreads; |
@@ -1976,7 +2053,7 @@ static HRESULT MethodBench( | |||
1976 | else | 2053 | else |
1977 | encoder.NumIterations = encoders[0].NumIterations; | 2054 | encoder.NumIterations = encoders[0].NumIterations; |
1978 | 2055 | ||
1979 | #ifndef _7ZIP_ST | 2056 | #ifndef Z7_ST |
1980 | { | 2057 | { |
1981 | int numSubThreads = method.Get_NumThreads(); | 2058 | int numSubThreads = method.Get_NumThreads(); |
1982 | encoder.NumDecoderSubThreads = (numSubThreads <= 0) ? 1 : (unsigned)numSubThreads; | 2059 | encoder.NumDecoderSubThreads = (numSubThreads <= 0) ? 1 : (unsigned)numSubThreads; |
@@ -1985,22 +2062,22 @@ static HRESULT MethodBench( | |||
1985 | { | 2062 | { |
1986 | for (UInt32 j = 0; j < numSubDecoderThreads; j++) | 2063 | for (UInt32 j = 0; j < numSubDecoderThreads; j++) |
1987 | { | 2064 | { |
1988 | HRESULT res = encoder.CreateDecoderThread(j, (i == 0 && j == 0) | 2065 | const HRESULT res = encoder.CreateDecoderThread(j, (i == 0 && j == 0) |
1989 | #ifdef USE_ALLOCA | 2066 | #ifdef USE_ALLOCA |
1990 | , ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF | 2067 | , ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF |
1991 | #endif | 2068 | #endif |
1992 | ); | 2069 | ); |
1993 | RINOK(res); | 2070 | RINOK(res) |
1994 | } | 2071 | } |
1995 | } | 2072 | } |
1996 | else | 2073 | else |
1997 | #endif | 2074 | #endif |
1998 | { | 2075 | { |
1999 | RINOK(encoder.Decode(0)); | 2076 | RINOK(encoder.Decode(0)) |
2000 | } | 2077 | } |
2001 | } | 2078 | } |
2002 | 2079 | ||
2003 | #ifndef _7ZIP_ST | 2080 | #ifndef Z7_ST |
2004 | if (mtDecoderMode) | 2081 | if (mtDecoderMode) |
2005 | { | 2082 | { |
2006 | WRes wres = 0; | 2083 | WRes wres = 0; |
@@ -2009,26 +2086,26 @@ static HRESULT MethodBench( | |||
2009 | for (UInt32 j = 0; j < numSubDecoderThreads; j++) | 2086 | for (UInt32 j = 0; j < numSubDecoderThreads; j++) |
2010 | { | 2087 | { |
2011 | CEncoderInfo &encoder = encoders[i]; | 2088 | CEncoderInfo &encoder = encoders[i]; |
2012 | WRes wres2 = encoder.thread[j]. | 2089 | const WRes wres2 = encoder.thread[j]. |
2013 | // Wait(); // later we can get thread times from thread in UNDER_CE | 2090 | // Wait(); // later we can get thread times from thread in UNDER_CE |
2014 | Wait_Close(); | 2091 | Wait_Close(); |
2015 | if (wres == 0 && wres2 != 0) | 2092 | if (wres == 0 && wres2 != 0) |
2016 | wres = wres2; | 2093 | wres = wres2; |
2017 | HRESULT res2 = encoder.Results[j]; | 2094 | const HRESULT res2 = encoder.Results[j]; |
2018 | if (res == 0 && res2 != 0) | 2095 | if (res == 0 && res2 != 0) |
2019 | res = res2; | 2096 | res = res2; |
2020 | } | 2097 | } |
2021 | if (wres != 0) | 2098 | if (wres != 0) |
2022 | return HRESULT_FROM_WIN32(wres); | 2099 | return HRESULT_FROM_WIN32(wres); |
2023 | RINOK(res); | 2100 | RINOK(res) |
2024 | } | 2101 | } |
2025 | #endif // _7ZIP_ST | 2102 | #endif // Z7_ST |
2026 | 2103 | ||
2027 | RINOK(status.Res); | 2104 | RINOK(status.Res) |
2028 | encoders[0].progressInfoSpec[0]->SetFinishTime(info); | 2105 | encoders[0].progressInfoSpec[0]->SetFinishTime(info); |
2029 | 2106 | ||
2030 | /* | 2107 | /* |
2031 | #ifndef _7ZIP_ST | 2108 | #ifndef Z7_ST |
2032 | #ifdef UNDER_CE | 2109 | #ifdef UNDER_CE |
2033 | if (mtDecoderMode) | 2110 | if (mtDecoderMode) |
2034 | for (i = 0; i < numEncoderThreads; i++) | 2111 | for (i = 0; i < numEncoderThreads; i++) |
@@ -2048,13 +2125,13 @@ static HRESULT MethodBench( | |||
2048 | 2125 | ||
2049 | for (i = 0; i < numEncoderThreads; i++) | 2126 | for (i = 0; i < numEncoderThreads; i++) |
2050 | { | 2127 | { |
2051 | CEncoderInfo &encoder = encoders[i]; | 2128 | const CEncoderInfo &encoder = encoders[i]; |
2052 | info.UnpackSize += encoder.kBufferSize; | 2129 | info.UnpackSize += encoder.kBufferSize; |
2053 | info.PackSize += encoder.compressedSize; | 2130 | info.PackSize += encoder.compressedSize; |
2054 | } | 2131 | } |
2055 | 2132 | ||
2056 | // RINOK(callback->SetDecodeResult(info, false)); // why we called before 21.03 ?? | 2133 | // RINOK(callback->SetDecodeResult(info, false)) // why we called before 21.03 ?? |
2057 | RINOK(callback->SetDecodeResult(info, true)); | 2134 | RINOK(callback->SetDecodeResult(info, true)) |
2058 | 2135 | ||
2059 | return S_OK; | 2136 | return S_OK; |
2060 | } | 2137 | } |
@@ -2234,7 +2311,7 @@ HRESULT CCrcInfo_Base::CrcProcess(UInt64 numIterations, | |||
2234 | if (cur - prev >= ((UInt32)1 << 30)) | 2311 | if (cur - prev >= ((UInt32)1 << 30)) |
2235 | { | 2312 | { |
2236 | prev = cur; | 2313 | prev = cur; |
2237 | RINOK(callback->CheckBreak()); | 2314 | RINOK(callback->CheckBreak()) |
2238 | } | 2315 | } |
2239 | } | 2316 | } |
2240 | } | 2317 | } |
@@ -2266,7 +2343,7 @@ static UInt32 CountCpuFreq(UInt32 sum, UInt32 num, UInt32 val) | |||
2266 | EXTERN_C_END | 2343 | EXTERN_C_END |
2267 | 2344 | ||
2268 | 2345 | ||
2269 | #ifndef _7ZIP_ST | 2346 | #ifndef Z7_ST |
2270 | 2347 | ||
2271 | struct CBaseThreadInfo | 2348 | struct CBaseThreadInfo |
2272 | { | 2349 | { |
@@ -2300,12 +2377,12 @@ static THREAD_FUNC_DECL FreqThreadFunction(void *param) | |||
2300 | { | 2377 | { |
2301 | p->CallbackRes = p->Callback->CheckBreak(); | 2378 | p->CallbackRes = p->Callback->CheckBreak(); |
2302 | if (p->CallbackRes != S_OK) | 2379 | if (p->CallbackRes != S_OK) |
2303 | return 0; | 2380 | break; |
2304 | } | 2381 | } |
2305 | sum = CountCpuFreq(sum, p->Size, g_BenchCpuFreqTemp); | 2382 | sum = CountCpuFreq(sum, p->Size, g_BenchCpuFreqTemp); |
2306 | } | 2383 | } |
2307 | p->ValRes = sum; | 2384 | p->ValRes = sum; |
2308 | return 0; | 2385 | return THREAD_FUNC_RET_ZERO; |
2309 | } | 2386 | } |
2310 | 2387 | ||
2311 | struct CFreqThreads | 2388 | struct CFreqThreads |
@@ -2349,7 +2426,7 @@ struct CCrcInfo: public CBaseThreadInfo | |||
2349 | HRESULT Res; | 2426 | HRESULT Res; |
2350 | UInt32 CheckSum_Res; | 2427 | UInt32 CheckSum_Res; |
2351 | 2428 | ||
2352 | #ifndef _7ZIP_ST | 2429 | #ifndef Z7_ST |
2353 | NSynchronization::CManualResetEvent ReadyEvent; | 2430 | NSynchronization::CManualResetEvent ReadyEvent; |
2354 | UInt32 ThreadIndex; | 2431 | UInt32 ThreadIndex; |
2355 | CBenchSyncCommon *Common; | 2432 | CBenchSyncCommon *Common; |
@@ -2433,7 +2510,7 @@ static THREAD_FUNC_DECL CrcThreadFunction(void *param) | |||
2433 | alloca(p->AllocaSize); | 2510 | alloca(p->AllocaSize); |
2434 | #endif | 2511 | #endif |
2435 | p->Process(); | 2512 | p->Process(); |
2436 | return 0; | 2513 | return THREAD_FUNC_RET_ZERO; |
2437 | } | 2514 | } |
2438 | 2515 | ||
2439 | 2516 | ||
@@ -2480,7 +2557,7 @@ WRes CCrcThreads::StartAndWait(bool exitMode) | |||
2480 | 2557 | ||
2481 | static UInt32 CrcCalc1(const Byte *buf, size_t size) | 2558 | static UInt32 CrcCalc1(const Byte *buf, size_t size) |
2482 | { | 2559 | { |
2483 | UInt32 crc = CRC_INIT_VAL;; | 2560 | UInt32 crc = CRC_INIT_VAL; |
2484 | for (size_t i = 0; i < size; i++) | 2561 | for (size_t i = 0; i < size; i++) |
2485 | crc = CRC_UPDATE_BYTE(crc, buf[i]); | 2562 | crc = CRC_UPDATE_BYTE(crc, buf[i]); |
2486 | return CRC_GET_DIGEST(crc); | 2563 | return CRC_GET_DIGEST(crc); |
@@ -2522,9 +2599,9 @@ struct CBenchMethod | |||
2522 | { | 2599 | { |
2523 | unsigned Weight; | 2600 | unsigned Weight; |
2524 | unsigned DictBits; | 2601 | unsigned DictBits; |
2525 | UInt32 EncComplex; | 2602 | Int32 EncComplex; |
2526 | UInt32 DecComplexCompr; | 2603 | Int32 DecComplexCompr; |
2527 | UInt32 DecComplexUnc; | 2604 | Int32 DecComplexUnc; |
2528 | const char *Name; | 2605 | const char *Name; |
2529 | // unsigned KeySize; | 2606 | // unsigned KeySize; |
2530 | }; | 2607 | }; |
@@ -2563,6 +2640,9 @@ static const CBenchMethod g_Bench[] = | |||
2563 | // { 10, 22, 1655, 0, 1830, "PPMDZip:x5" }, | 2640 | // { 10, 22, 1655, 0, 1830, "PPMDZip:x5" }, |
2564 | { 10, 22, 1655, 0, 1830, "PPMD:x5" }, | 2641 | { 10, 22, 1655, 0, 1830, "PPMD:x5" }, |
2565 | 2642 | ||
2643 | // { 2, 0, -16, 0, -16, "Swap2" }, | ||
2644 | { 2, 0, -16, 0, -16, "Swap4" }, | ||
2645 | |||
2566 | // { 2, 0, 3, 0, 4, "Delta:1" }, | 2646 | // { 2, 0, 3, 0, 4, "Delta:1" }, |
2567 | // { 2, 0, 3, 0, 4, "Delta:2" }, | 2647 | // { 2, 0, 3, 0, 4, "Delta:2" }, |
2568 | // { 2, 0, 3, 0, 4, "Delta:3" }, | 2648 | // { 2, 0, 3, 0, 4, "Delta:3" }, |
@@ -2570,8 +2650,9 @@ static const CBenchMethod g_Bench[] = | |||
2570 | // { 2, 0, 3, 0, 4, "Delta:8" }, | 2650 | // { 2, 0, 3, 0, 4, "Delta:8" }, |
2571 | // { 2, 0, 3, 0, 4, "Delta:32" }, | 2651 | // { 2, 0, 3, 0, 4, "Delta:32" }, |
2572 | 2652 | ||
2573 | { 2, 0, 4, 0, 4, "BCJ" }, | 2653 | { 2, 0, 2, 0, 2, "BCJ" }, |
2574 | 2654 | { 2, 0, 1, 0, 1, "ARM64" }, | |
2655 | |||
2575 | // { 10, 0, 18, 0, 18, "AES128CBC:1" }, | 2656 | // { 10, 0, 18, 0, 18, "AES128CBC:1" }, |
2576 | // { 10, 0, 21, 0, 21, "AES192CBC:1" }, | 2657 | // { 10, 0, 21, 0, 21, "AES192CBC:1" }, |
2577 | { 10, 0, 24, 0, 24, "AES256CBC:1" }, | 2658 | { 10, 0, 24, 0, 24, "AES256CBC:1" }, |
@@ -2607,11 +2688,13 @@ struct CBenchHash | |||
2607 | // #define ARM_CRC_MUL 100 | 2688 | // #define ARM_CRC_MUL 100 |
2608 | #define ARM_CRC_MUL 1 | 2689 | #define ARM_CRC_MUL 1 |
2609 | 2690 | ||
2691 | #define k_Hash_Complex_Mult 256 | ||
2692 | |||
2610 | static const CBenchHash g_Hash[] = | 2693 | static const CBenchHash g_Hash[] = |
2611 | { | 2694 | { |
2612 | { 1, 1820, 0x21e207bb, "CRC32:1" }, | 2695 | // { 1, 1820, 0x21e207bb, "CRC32:1" }, |
2613 | { 10, 558, 0x21e207bb, "CRC32:4" }, | 2696 | // { 10, 558, 0x21e207bb, "CRC32:4" }, |
2614 | { 10, 339, 0x21e207bb, "CRC32:8" } , | 2697 | { 20, 339, 0x21e207bb, "CRC32:8" } , |
2615 | { 2, 128 *ARM_CRC_MUL, 0x21e207bb, "CRC32:32" }, | 2698 | { 2, 128 *ARM_CRC_MUL, 0x21e207bb, "CRC32:32" }, |
2616 | { 2, 64 *ARM_CRC_MUL, 0x21e207bb, "CRC32:64" }, | 2699 | { 2, 64 *ARM_CRC_MUL, 0x21e207bb, "CRC32:64" }, |
2617 | { 10, 512, 0x41b901d1, "CRC64" }, | 2700 | { 10, 512, 0x41b901d1, "CRC64" }, |
@@ -2656,6 +2739,8 @@ static const unsigned kFieldSize_RU = 6; | |||
2656 | static const unsigned kFieldSize_Rating = 6; | 2739 | static const unsigned kFieldSize_Rating = 6; |
2657 | static const unsigned kFieldSize_EU = 5; | 2740 | static const unsigned kFieldSize_EU = 5; |
2658 | static const unsigned kFieldSize_Effec = 5; | 2741 | static const unsigned kFieldSize_Effec = 5; |
2742 | static const unsigned kFieldSize_CrcSpeed = 8; | ||
2743 | |||
2659 | 2744 | ||
2660 | static const unsigned kFieldSize_TotalSize = 4 + kFieldSize_Speed + kFieldSize_Usage + kFieldSize_RU + kFieldSize_Rating; | 2745 | static const unsigned kFieldSize_TotalSize = 4 + kFieldSize_Speed + kFieldSize_Usage + kFieldSize_RU + kFieldSize_Rating; |
2661 | static const unsigned kFieldSize_EUAndEffec = 2 + kFieldSize_EU + kFieldSize_Effec; | 2746 | static const unsigned kFieldSize_EUAndEffec = 2 + kFieldSize_EU + kFieldSize_Effec; |
@@ -2830,7 +2915,7 @@ AString GetProcessThreadsInfo(const NSystem::CProcessAffinity &ti) | |||
2830 | } | 2915 | } |
2831 | 2916 | ||
2832 | 2917 | ||
2833 | #ifdef _7ZIP_LARGE_PAGES | 2918 | #ifdef Z7_LARGE_PAGES |
2834 | 2919 | ||
2835 | #ifdef _WIN32 | 2920 | #ifdef _WIN32 |
2836 | extern bool g_LargePagesMode; | 2921 | extern bool g_LargePagesMode; |
@@ -2875,7 +2960,7 @@ static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString, | |||
2875 | f.Print(" ?"); | 2960 | f.Print(" ?"); |
2876 | f.Print(" MB"); | 2961 | f.Print(" MB"); |
2877 | 2962 | ||
2878 | #ifdef _7ZIP_LARGE_PAGES | 2963 | #ifdef Z7_LARGE_PAGES |
2879 | { | 2964 | { |
2880 | AString s; | 2965 | AString s; |
2881 | Add_LargePages_String(s); | 2966 | Add_LargePages_String(s); |
@@ -2890,30 +2975,34 @@ static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString, | |||
2890 | 2975 | ||
2891 | 2976 | ||
2892 | 2977 | ||
2893 | struct CBenchCallbackToPrint: public IBenchCallback | 2978 | struct CBenchCallbackToPrint Z7_final: public IBenchCallback |
2894 | { | 2979 | { |
2895 | CBenchProps BenchProps; | 2980 | bool NeedPrint; |
2896 | CTotalBenchRes EncodeRes; | ||
2897 | CTotalBenchRes DecodeRes; | ||
2898 | IBenchPrintCallback *_file; | ||
2899 | UInt64 DictSize; | ||
2900 | |||
2901 | bool Use2Columns; | 2981 | bool Use2Columns; |
2902 | unsigned NameFieldSize; | ||
2903 | |||
2904 | bool ShowFreq; | 2982 | bool ShowFreq; |
2905 | UInt64 CpuFreq; | 2983 | unsigned NameFieldSize; |
2906 | 2984 | ||
2907 | unsigned EncodeWeight; | 2985 | unsigned EncodeWeight; |
2908 | unsigned DecodeWeight; | 2986 | unsigned DecodeWeight; |
2909 | 2987 | ||
2988 | UInt64 CpuFreq; | ||
2989 | UInt64 DictSize; | ||
2990 | |||
2991 | IBenchPrintCallback *_file; | ||
2992 | CBenchProps BenchProps; | ||
2993 | CTotalBenchRes EncodeRes; | ||
2994 | CTotalBenchRes DecodeRes; | ||
2995 | |||
2996 | CBenchInfo BenchInfo_Results[2]; | ||
2997 | |||
2910 | CBenchCallbackToPrint(): | 2998 | CBenchCallbackToPrint(): |
2999 | NeedPrint(true), | ||
2911 | Use2Columns(false), | 3000 | Use2Columns(false), |
2912 | NameFieldSize(0), | ||
2913 | ShowFreq(false), | 3001 | ShowFreq(false), |
2914 | CpuFreq(0), | 3002 | NameFieldSize(0), |
2915 | EncodeWeight(1), | 3003 | EncodeWeight(1), |
2916 | DecodeWeight(1) | 3004 | DecodeWeight(1), |
3005 | CpuFreq(0) | ||
2917 | {} | 3006 | {} |
2918 | 3007 | ||
2919 | void Init() { EncodeRes.Init(); DecodeRes.Init(); } | 3008 | void Init() { EncodeRes.Init(); DecodeRes.Init(); } |
@@ -2921,8 +3010,8 @@ struct CBenchCallbackToPrint: public IBenchCallback | |||
2921 | void NewLine(); | 3010 | void NewLine(); |
2922 | 3011 | ||
2923 | HRESULT SetFreq(bool showFreq, UInt64 cpuFreq); | 3012 | HRESULT SetFreq(bool showFreq, UInt64 cpuFreq); |
2924 | HRESULT SetEncodeResult(const CBenchInfo &info, bool final); | 3013 | HRESULT SetEncodeResult(const CBenchInfo &info, bool final) Z7_override; |
2925 | HRESULT SetDecodeResult(const CBenchInfo &info, bool final); | 3014 | HRESULT SetDecodeResult(const CBenchInfo &info, bool final) Z7_override; |
2926 | }; | 3015 | }; |
2927 | 3016 | ||
2928 | HRESULT CBenchCallbackToPrint::SetFreq(bool showFreq, UInt64 cpuFreq) | 3017 | HRESULT CBenchCallbackToPrint::SetFreq(bool showFreq, UInt64 cpuFreq) |
@@ -2934,10 +3023,13 @@ HRESULT CBenchCallbackToPrint::SetFreq(bool showFreq, UInt64 cpuFreq) | |||
2934 | 3023 | ||
2935 | HRESULT CBenchCallbackToPrint::SetEncodeResult(const CBenchInfo &info, bool final) | 3024 | HRESULT CBenchCallbackToPrint::SetEncodeResult(const CBenchInfo &info, bool final) |
2936 | { | 3025 | { |
2937 | RINOK(_file->CheckBreak()); | 3026 | RINOK(_file->CheckBreak()) |
2938 | if (final) | 3027 | if (final) |
3028 | BenchInfo_Results[0] = info; | ||
3029 | if (final) | ||
3030 | if (NeedPrint) | ||
2939 | { | 3031 | { |
2940 | UInt64 rating = BenchProps.GetCompressRating(DictSize, info.GlobalTime, info.GlobalFreq, info.UnpackSize * info.NumIterations); | 3032 | const UInt64 rating = BenchProps.GetRating_Enc(DictSize, info.GlobalTime, info.GlobalFreq, info.UnpackSize * info.NumIterations); |
2941 | PrintResults(_file, info, | 3033 | PrintResults(_file, info, |
2942 | EncodeWeight, rating, | 3034 | EncodeWeight, rating, |
2943 | ShowFreq, CpuFreq, &EncodeRes); | 3035 | ShowFreq, CpuFreq, &EncodeRes); |
@@ -2951,10 +3043,13 @@ static const char * const kSep = " | "; | |||
2951 | 3043 | ||
2952 | HRESULT CBenchCallbackToPrint::SetDecodeResult(const CBenchInfo &info, bool final) | 3044 | HRESULT CBenchCallbackToPrint::SetDecodeResult(const CBenchInfo &info, bool final) |
2953 | { | 3045 | { |
2954 | RINOK(_file->CheckBreak()); | 3046 | RINOK(_file->CheckBreak()) |
3047 | if (final) | ||
3048 | BenchInfo_Results[1] = info; | ||
2955 | if (final) | 3049 | if (final) |
3050 | if (NeedPrint) | ||
2956 | { | 3051 | { |
2957 | UInt64 rating = BenchProps.GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations); | 3052 | const UInt64 rating = BenchProps.GetRating_Dec(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations); |
2958 | if (Use2Columns) | 3053 | if (Use2Columns) |
2959 | _file->Print(kSep); | 3054 | _file->Print(kSep); |
2960 | else | 3055 | else |
@@ -2996,10 +3091,22 @@ static void PrintRight(IBenchPrintCallback &f, const char *s, unsigned size) | |||
2996 | f.Print(s); | 3091 | f.Print(s); |
2997 | } | 3092 | } |
2998 | 3093 | ||
3094 | |||
3095 | static bool DoesWildcardMatchName_NoCase(const AString &mask, const char *name) | ||
3096 | { | ||
3097 | UString wildc = GetUnicodeString(mask); | ||
3098 | UString bname = GetUnicodeString(name); | ||
3099 | wildc.MakeLower_Ascii(); | ||
3100 | bname.MakeLower_Ascii(); | ||
3101 | return DoesWildcardMatchName(wildc, bname); | ||
3102 | } | ||
3103 | |||
3104 | |||
2999 | static HRESULT TotalBench( | 3105 | static HRESULT TotalBench( |
3000 | DECL_EXTERNAL_CODECS_LOC_VARS | 3106 | DECL_EXTERNAL_CODECS_LOC_VARS |
3107 | const COneMethodInfo &methodMask, | ||
3001 | UInt64 complexInCommands, | 3108 | UInt64 complexInCommands, |
3002 | #ifndef _7ZIP_ST | 3109 | #ifndef Z7_ST |
3003 | UInt32 numThreads, | 3110 | UInt32 numThreads, |
3004 | const CAffinityMode *affinityMode, | 3111 | const CAffinityMode *affinityMode, |
3005 | #endif | 3112 | #endif |
@@ -3008,9 +3115,11 @@ static HRESULT TotalBench( | |||
3008 | const Byte *fileData, | 3115 | const Byte *fileData, |
3009 | IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback) | 3116 | IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback) |
3010 | { | 3117 | { |
3011 | for (unsigned i = 0; i < ARRAY_SIZE(g_Bench); i++) | 3118 | for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_Bench); i++) |
3012 | { | 3119 | { |
3013 | const CBenchMethod &bench = g_Bench[i]; | 3120 | const CBenchMethod &bench = g_Bench[i]; |
3121 | if (!DoesWildcardMatchName_NoCase(methodMask.MethodName, bench.Name)) | ||
3122 | continue; | ||
3014 | PrintLeft(*callback->_file, bench.Name, kFieldSize_Name); | 3123 | PrintLeft(*callback->_file, bench.Name, kFieldSize_Name); |
3015 | { | 3124 | { |
3016 | unsigned keySize = 32; | 3125 | unsigned keySize = 32; |
@@ -3025,7 +3134,7 @@ static HRESULT TotalBench( | |||
3025 | COneMethodInfo method; | 3134 | COneMethodInfo method; |
3026 | NCOM::CPropVariant propVariant; | 3135 | NCOM::CPropVariant propVariant; |
3027 | propVariant = bench.Name; | 3136 | propVariant = bench.Name; |
3028 | RINOK(method.ParseMethodFromPROPVARIANT(UString(), propVariant)); | 3137 | RINOK(method.ParseMethodFromPROPVARIANT(UString(), propVariant)) |
3029 | 3138 | ||
3030 | size_t unpackSize2 = unpackSize; | 3139 | size_t unpackSize2 = unpackSize; |
3031 | if (!forceUnpackSize && bench.DictBits == 0) | 3140 | if (!forceUnpackSize && bench.DictBits == 0) |
@@ -3034,10 +3143,10 @@ static HRESULT TotalBench( | |||
3034 | callback->EncodeWeight = bench.Weight; | 3143 | callback->EncodeWeight = bench.Weight; |
3035 | callback->DecodeWeight = bench.Weight; | 3144 | callback->DecodeWeight = bench.Weight; |
3036 | 3145 | ||
3037 | HRESULT res = MethodBench( | 3146 | const HRESULT res = MethodBench( |
3038 | EXTERNAL_CODECS_LOC_VARS | 3147 | EXTERNAL_CODECS_LOC_VARS |
3039 | complexInCommands, | 3148 | complexInCommands, |
3040 | #ifndef _7ZIP_ST | 3149 | #ifndef Z7_ST |
3041 | false, numThreads, affinityMode, | 3150 | false, numThreads, affinityMode, |
3042 | #endif | 3151 | #endif |
3043 | method, | 3152 | method, |
@@ -3054,7 +3163,7 @@ static HRESULT TotalBench( | |||
3054 | } | 3163 | } |
3055 | else | 3164 | else |
3056 | { | 3165 | { |
3057 | RINOK(res); | 3166 | RINOK(res) |
3058 | } | 3167 | } |
3059 | 3168 | ||
3060 | callback->NewLine(); | 3169 | callback->NewLine(); |
@@ -3080,7 +3189,7 @@ struct CFreqBench | |||
3080 | {} | 3189 | {} |
3081 | 3190 | ||
3082 | HRESULT FreqBench(IBenchPrintCallback *_file | 3191 | HRESULT FreqBench(IBenchPrintCallback *_file |
3083 | #ifndef _7ZIP_ST | 3192 | #ifndef Z7_ST |
3084 | , const CAffinityMode *affinityMode | 3193 | , const CAffinityMode *affinityMode |
3085 | #endif | 3194 | #endif |
3086 | ); | 3195 | ); |
@@ -3088,7 +3197,7 @@ struct CFreqBench | |||
3088 | 3197 | ||
3089 | 3198 | ||
3090 | HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file | 3199 | HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file |
3091 | #ifndef _7ZIP_ST | 3200 | #ifndef Z7_ST |
3092 | , const CAffinityMode *affinityMode | 3201 | , const CAffinityMode *affinityMode |
3093 | #endif | 3202 | #endif |
3094 | ) | 3203 | ) |
@@ -3100,7 +3209,7 @@ HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file | |||
3100 | if (numThreads == 0) | 3209 | if (numThreads == 0) |
3101 | numThreads = 1; | 3210 | numThreads = 1; |
3102 | 3211 | ||
3103 | #ifdef _7ZIP_ST | 3212 | #ifdef Z7_ST |
3104 | numThreads = 1; | 3213 | numThreads = 1; |
3105 | #endif | 3214 | #endif |
3106 | 3215 | ||
@@ -3117,7 +3226,7 @@ HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file | |||
3117 | 3226 | ||
3118 | CBenchInfoCalc progressInfoSpec; | 3227 | CBenchInfoCalc progressInfoSpec; |
3119 | 3228 | ||
3120 | #ifndef _7ZIP_ST | 3229 | #ifndef Z7_ST |
3121 | 3230 | ||
3122 | bool mtMode = (numThreads > 1) || affinityMode->NeedAffinity(); | 3231 | bool mtMode = (numThreads > 1) || affinityMode->NeedAffinity(); |
3123 | 3232 | ||
@@ -3150,7 +3259,7 @@ HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file | |||
3150 | return HRESULT_FROM_WIN32(wres); | 3259 | return HRESULT_FROM_WIN32(wres); |
3151 | for (i = 0; i < numThreads; i++) | 3260 | for (i = 0; i < numThreads; i++) |
3152 | { | 3261 | { |
3153 | RINOK(threads.Items[i].CallbackRes); | 3262 | RINOK(threads.Items[i].CallbackRes) |
3154 | } | 3263 | } |
3155 | } | 3264 | } |
3156 | else | 3265 | else |
@@ -3163,7 +3272,7 @@ HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file | |||
3163 | sum = CountCpuFreq(sum, numIterations2, g_BenchCpuFreqTemp); | 3272 | sum = CountCpuFreq(sum, numIterations2, g_BenchCpuFreqTemp); |
3164 | if (_file) | 3273 | if (_file) |
3165 | { | 3274 | { |
3166 | RINOK(_file->CheckBreak()); | 3275 | RINOK(_file->CheckBreak()) |
3167 | } | 3276 | } |
3168 | } | 3277 | } |
3169 | res += sum; | 3278 | res += sum; |
@@ -3172,7 +3281,7 @@ HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file | |||
3172 | if (res == 0x12345678) | 3281 | if (res == 0x12345678) |
3173 | if (_file) | 3282 | if (_file) |
3174 | { | 3283 | { |
3175 | RINOK(_file->CheckBreak()); | 3284 | RINOK(_file->CheckBreak()) |
3176 | } | 3285 | } |
3177 | 3286 | ||
3178 | CBenchInfo info; | 3287 | CBenchInfo info; |
@@ -3193,7 +3302,7 @@ HRESULT CFreqBench::FreqBench(IBenchPrintCallback *_file | |||
3193 | 0, // weight | 3302 | 0, // weight |
3194 | rating, | 3303 | rating, |
3195 | showFreq, showFreq ? (specifiedFreq != 0 ? specifiedFreq : CpuFreqRes) : 0, NULL); | 3304 | showFreq, showFreq ? (specifiedFreq != 0 ? specifiedFreq : CpuFreqRes) : 0, NULL); |
3196 | RINOK(_file->CheckBreak()); | 3305 | RINOK(_file->CheckBreak()) |
3197 | } | 3306 | } |
3198 | 3307 | ||
3199 | return S_OK; | 3308 | return S_OK; |
@@ -3215,7 +3324,7 @@ static HRESULT CrcBench( | |||
3215 | const UInt32 *checkSum, | 3324 | const UInt32 *checkSum, |
3216 | const COneMethodInfo &method, | 3325 | const COneMethodInfo &method, |
3217 | IBenchPrintCallback *_file, | 3326 | IBenchPrintCallback *_file, |
3218 | #ifndef _7ZIP_ST | 3327 | #ifndef Z7_ST |
3219 | const CAffinityMode *affinityMode, | 3328 | const CAffinityMode *affinityMode, |
3220 | #endif | 3329 | #endif |
3221 | bool showRating, | 3330 | bool showRating, |
@@ -3225,7 +3334,7 @@ static HRESULT CrcBench( | |||
3225 | if (numThreads == 0) | 3334 | if (numThreads == 0) |
3226 | numThreads = 1; | 3335 | numThreads = 1; |
3227 | 3336 | ||
3228 | #ifdef _7ZIP_ST | 3337 | #ifdef Z7_ST |
3229 | numThreads = 1; | 3338 | numThreads = 1; |
3230 | #endif | 3339 | #endif |
3231 | 3340 | ||
@@ -3249,14 +3358,14 @@ static HRESULT CrcBench( | |||
3249 | */ | 3358 | */ |
3250 | 3359 | ||
3251 | const size_t bsize = (bufferSize == 0 ? 1 : bufferSize); | 3360 | const size_t bsize = (bufferSize == 0 ? 1 : bufferSize); |
3252 | UInt64 numIterations = complexInCommands * 256 / complexity / bsize; | 3361 | UInt64 numIterations = complexInCommands * k_Hash_Complex_Mult / complexity / bsize; |
3253 | if (numIterations == 0) | 3362 | if (numIterations == 0) |
3254 | numIterations = 1; | 3363 | numIterations = 1; |
3255 | 3364 | ||
3256 | CBenchInfoCalc progressInfoSpec; | 3365 | CBenchInfoCalc progressInfoSpec; |
3257 | CBenchInfo info; | 3366 | CBenchInfo info; |
3258 | 3367 | ||
3259 | #ifndef _7ZIP_ST | 3368 | #ifndef Z7_ST |
3260 | bool mtEncMode = (numThreads > 1) || affinityMode->NeedAffinity(); | 3369 | bool mtEncMode = (numThreads > 1) || affinityMode->NeedAffinity(); |
3261 | 3370 | ||
3262 | if (mtEncMode) | 3371 | if (mtEncMode) |
@@ -3275,14 +3384,14 @@ static HRESULT CrcBench( | |||
3275 | { | 3384 | { |
3276 | CCrcInfo &ci = threads.Items[i]; | 3385 | CCrcInfo &ci = threads.Items[i]; |
3277 | AString name; | 3386 | AString name; |
3278 | RINOK(CreateHasher(EXTERNAL_CODECS_LOC_VARS hashID, name, ci.Hasher)); | 3387 | RINOK(CreateHasher(EXTERNAL_CODECS_LOC_VARS hashID, name, ci.Hasher)) |
3279 | if (!ci.Hasher) | 3388 | if (!ci.Hasher) |
3280 | return E_NOTIMPL; | 3389 | return E_NOTIMPL; |
3281 | CMyComPtr<ICompressSetCoderProperties> scp; | 3390 | CMyComPtr<ICompressSetCoderProperties> scp; |
3282 | ci.Hasher.QueryInterface(IID_ICompressSetCoderProperties, &scp); | 3391 | ci.Hasher.QueryInterface(IID_ICompressSetCoderProperties, &scp); |
3283 | if (scp) | 3392 | if (scp) |
3284 | { | 3393 | { |
3285 | RINOK(method.SetCoderProps(scp)); | 3394 | RINOK(method.SetCoderProps(scp)) |
3286 | } | 3395 | } |
3287 | 3396 | ||
3288 | ci.Callback = _file; | 3397 | ci.Callback = _file; |
@@ -3320,7 +3429,7 @@ static HRESULT CrcBench( | |||
3320 | WRes wres = ci.ReadyEvent.Lock(); | 3429 | WRes wres = ci.ReadyEvent.Lock(); |
3321 | if (wres != 0) | 3430 | if (wres != 0) |
3322 | return HRESULT_FROM_WIN32(wres); | 3431 | return HRESULT_FROM_WIN32(wres); |
3323 | RINOK(ci.Res); | 3432 | RINOK(ci.Res) |
3324 | } | 3433 | } |
3325 | 3434 | ||
3326 | progressInfoSpec.SetStartTime(); | 3435 | progressInfoSpec.SetStartTime(); |
@@ -3333,7 +3442,7 @@ static HRESULT CrcBench( | |||
3333 | 3442 | ||
3334 | for (i = 0; i < numThreads; i++) | 3443 | for (i = 0; i < numThreads; i++) |
3335 | { | 3444 | { |
3336 | RINOK(threads.Items[i].Res); | 3445 | RINOK(threads.Items[i].Res) |
3337 | if (i != 0) | 3446 | if (i != 0) |
3338 | if (threads.Items[i].CheckSum_Res != | 3447 | if (threads.Items[i].CheckSum_Res != |
3339 | threads.Items[i - 1].CheckSum_Res) | 3448 | threads.Items[i - 1].CheckSum_Res) |
@@ -3345,20 +3454,20 @@ static HRESULT CrcBench( | |||
3345 | { | 3454 | { |
3346 | CMyComPtr<IHasher> hasher; | 3455 | CMyComPtr<IHasher> hasher; |
3347 | AString name; | 3456 | AString name; |
3348 | RINOK(CreateHasher(EXTERNAL_CODECS_LOC_VARS hashID, name, hasher)); | 3457 | RINOK(CreateHasher(EXTERNAL_CODECS_LOC_VARS hashID, name, hasher)) |
3349 | if (!hasher) | 3458 | if (!hasher) |
3350 | return E_NOTIMPL; | 3459 | return E_NOTIMPL; |
3351 | CMyComPtr<ICompressSetCoderProperties> scp; | 3460 | CMyComPtr<ICompressSetCoderProperties> scp; |
3352 | hasher.QueryInterface(IID_ICompressSetCoderProperties, &scp); | 3461 | hasher.QueryInterface(IID_ICompressSetCoderProperties, &scp); |
3353 | if (scp) | 3462 | if (scp) |
3354 | { | 3463 | { |
3355 | RINOK(method.SetCoderProps(scp)); | 3464 | RINOK(method.SetCoderProps(scp)) |
3356 | } | 3465 | } |
3357 | CCrcInfo_Base crcib; | 3466 | CCrcInfo_Base crcib; |
3358 | crcib.CreateLocalBuf = false; | 3467 | crcib.CreateLocalBuf = false; |
3359 | RINOK(crcib.Generate(fileData, bufferSize)); | 3468 | RINOK(crcib.Generate(fileData, bufferSize)) |
3360 | progressInfoSpec.SetStartTime(); | 3469 | progressInfoSpec.SetStartTime(); |
3361 | RINOK(crcib.CrcProcess(numIterations, checkSum, hasher, _file)); | 3470 | RINOK(crcib.CrcProcess(numIterations, checkSum, hasher, _file)) |
3362 | progressInfoSpec.SetFinishTime(info); | 3471 | progressInfoSpec.SetFinishTime(info); |
3363 | } | 3472 | } |
3364 | 3473 | ||
@@ -3382,7 +3491,7 @@ static HRESULT CrcBench( | |||
3382 | benchWeight, rating, | 3491 | benchWeight, rating, |
3383 | showFreq, cpuFreq, encodeRes); | 3492 | showFreq, cpuFreq, encodeRes); |
3384 | } | 3493 | } |
3385 | RINOK(_file->CheckBreak()); | 3494 | RINOK(_file->CheckBreak()) |
3386 | } | 3495 | } |
3387 | 3496 | ||
3388 | speed = info.GetSpeed(unpSizeThreads); | 3497 | speed = info.GetSpeed(unpSizeThreads); |
@@ -3395,20 +3504,23 @@ static HRESULT CrcBench( | |||
3395 | 3504 | ||
3396 | static HRESULT TotalBench_Hash( | 3505 | static HRESULT TotalBench_Hash( |
3397 | DECL_EXTERNAL_CODECS_LOC_VARS | 3506 | DECL_EXTERNAL_CODECS_LOC_VARS |
3507 | const COneMethodInfo &methodMask, | ||
3398 | UInt64 complexInCommands, | 3508 | UInt64 complexInCommands, |
3399 | UInt32 numThreads, | 3509 | UInt32 numThreads, |
3400 | size_t bufSize, | 3510 | size_t bufSize, |
3401 | const Byte *fileData, | 3511 | const Byte *fileData, |
3402 | IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback, | 3512 | IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback, |
3403 | #ifndef _7ZIP_ST | 3513 | #ifndef Z7_ST |
3404 | const CAffinityMode *affinityMode, | 3514 | const CAffinityMode *affinityMode, |
3405 | #endif | 3515 | #endif |
3406 | CTotalBenchRes *encodeRes, | 3516 | CTotalBenchRes *encodeRes, |
3407 | bool showFreq, UInt64 cpuFreq) | 3517 | bool showFreq, UInt64 cpuFreq) |
3408 | { | 3518 | { |
3409 | for (unsigned i = 0; i < ARRAY_SIZE(g_Hash); i++) | 3519 | for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_Hash); i++) |
3410 | { | 3520 | { |
3411 | const CBenchHash &bench = g_Hash[i]; | 3521 | const CBenchHash &bench = g_Hash[i]; |
3522 | if (!DoesWildcardMatchName_NoCase(methodMask.MethodName, bench.Name)) | ||
3523 | continue; | ||
3412 | PrintLeft(*callback->_file, bench.Name, kFieldSize_Name); | 3524 | PrintLeft(*callback->_file, bench.Name, kFieldSize_Name); |
3413 | // callback->BenchProps.DecComplexUnc = bench.DecComplexUnc; | 3525 | // callback->BenchProps.DecComplexUnc = bench.DecComplexUnc; |
3414 | // callback->BenchProps.DecComplexCompr = bench.DecComplexCompr; | 3526 | // callback->BenchProps.DecComplexCompr = bench.DecComplexCompr; |
@@ -3417,11 +3529,11 @@ static HRESULT TotalBench_Hash( | |||
3417 | COneMethodInfo method; | 3529 | COneMethodInfo method; |
3418 | NCOM::CPropVariant propVariant; | 3530 | NCOM::CPropVariant propVariant; |
3419 | propVariant = bench.Name; | 3531 | propVariant = bench.Name; |
3420 | RINOK(method.ParseMethodFromPROPVARIANT(UString(), propVariant)); | 3532 | RINOK(method.ParseMethodFromPROPVARIANT(UString(), propVariant)) |
3421 | 3533 | ||
3422 | UInt64 speed, usage; | 3534 | UInt64 speed, usage; |
3423 | 3535 | ||
3424 | HRESULT res = CrcBench( | 3536 | const HRESULT res = CrcBench( |
3425 | EXTERNAL_CODECS_LOC_VARS | 3537 | EXTERNAL_CODECS_LOC_VARS |
3426 | complexInCommands, | 3538 | complexInCommands, |
3427 | numThreads, bufSize, fileData, | 3539 | numThreads, bufSize, fileData, |
@@ -3430,7 +3542,7 @@ static HRESULT TotalBench_Hash( | |||
3430 | (!fileData && bufSize == (1 << kNumHashDictBits)) ? &bench.CheckSum : NULL, | 3542 | (!fileData && bufSize == (1 << kNumHashDictBits)) ? &bench.CheckSum : NULL, |
3431 | method, | 3543 | method, |
3432 | printCallback, | 3544 | printCallback, |
3433 | #ifndef _7ZIP_ST | 3545 | #ifndef Z7_ST |
3434 | affinityMode, | 3546 | affinityMode, |
3435 | #endif | 3547 | #endif |
3436 | true, // showRating | 3548 | true, // showRating |
@@ -3441,7 +3553,7 @@ static HRESULT TotalBench_Hash( | |||
3441 | } | 3553 | } |
3442 | else | 3554 | else |
3443 | { | 3555 | { |
3444 | RINOK(res); | 3556 | RINOK(res) |
3445 | } | 3557 | } |
3446 | callback->NewLine(); | 3558 | callback->NewLine(); |
3447 | } | 3559 | } |
@@ -3451,7 +3563,8 @@ static HRESULT TotalBench_Hash( | |||
3451 | struct CTempValues | 3563 | struct CTempValues |
3452 | { | 3564 | { |
3453 | UInt64 *Values; | 3565 | UInt64 *Values; |
3454 | CTempValues(UInt32 num) { Values = new UInt64[num]; } | 3566 | CTempValues(): Values(NULL) {} |
3567 | void Alloc(UInt32 num) { Values = new UInt64[num]; } | ||
3455 | ~CTempValues() { delete []Values; } | 3568 | ~CTempValues() { delete []Values; } |
3456 | }; | 3569 | }; |
3457 | 3570 | ||
@@ -3482,6 +3595,29 @@ static void Print_Usage_and_Threads(IBenchPrintCallback &f, UInt64 usage, UInt32 | |||
3482 | } | 3595 | } |
3483 | 3596 | ||
3484 | 3597 | ||
3598 | static void Print_Delimiter(IBenchPrintCallback &f) | ||
3599 | { | ||
3600 | f.Print(" |"); | ||
3601 | } | ||
3602 | |||
3603 | static void Print_Pow(IBenchPrintCallback &f, unsigned pow) | ||
3604 | { | ||
3605 | char s[16]; | ||
3606 | ConvertUInt32ToString(pow, s); | ||
3607 | unsigned pos = MyStringLen(s); | ||
3608 | s[pos++] = ':'; | ||
3609 | s[pos] = 0; | ||
3610 | PrintLeft(f, s, kFieldSize_SmallName); // 4 | ||
3611 | } | ||
3612 | |||
3613 | static void Bench_BW_Print_Usage_Speed(IBenchPrintCallback &f, | ||
3614 | UInt64 usage, UInt64 speed) | ||
3615 | { | ||
3616 | PrintUsage(f, usage, kFieldSize_Usage); | ||
3617 | PrintNumber(f, speed / 1000000, kFieldSize_CrcSpeed); | ||
3618 | } | ||
3619 | |||
3620 | |||
3485 | HRESULT Bench( | 3621 | HRESULT Bench( |
3486 | DECL_EXTERNAL_CODECS_LOC_VARS | 3622 | DECL_EXTERNAL_CODECS_LOC_VARS |
3487 | IBenchPrintCallback *printCallback, | 3623 | IBenchPrintCallback *printCallback, |
@@ -3500,7 +3636,7 @@ HRESULT Bench( | |||
3500 | NSystem::CProcessAffinity threadsInfo; | 3636 | NSystem::CProcessAffinity threadsInfo; |
3501 | threadsInfo.InitST(); | 3637 | threadsInfo.InitST(); |
3502 | 3638 | ||
3503 | #ifndef _7ZIP_ST | 3639 | #ifndef Z7_ST |
3504 | 3640 | ||
3505 | if (threadsInfo.Get() && threadsInfo.GetNumProcessThreads() != 0) | 3641 | if (threadsInfo.Get() && threadsInfo.GetNumProcessThreads() != 0) |
3506 | numCPUs = threadsInfo.GetNumProcessThreads(); | 3642 | numCPUs = threadsInfo.GetNumProcessThreads(); |
@@ -3533,7 +3669,7 @@ HRESULT Bench( | |||
3533 | UInt64 complexInCommands = kComplexInCommands; | 3669 | UInt64 complexInCommands = kComplexInCommands; |
3534 | UInt32 numThreads_Start = 1; | 3670 | UInt32 numThreads_Start = 1; |
3535 | 3671 | ||
3536 | #ifndef _7ZIP_ST | 3672 | #ifndef Z7_ST |
3537 | CAffinityMode affinityMode; | 3673 | CAffinityMode affinityMode; |
3538 | #endif | 3674 | #endif |
3539 | 3675 | ||
@@ -3597,7 +3733,7 @@ HRESULT Bench( | |||
3597 | 3733 | ||
3598 | // (len == 0) is allowed. Also it's allowed if Alloc(0) returns NULL here | 3734 | // (len == 0) is allowed. Also it's allowed if Alloc(0) returns NULL here |
3599 | 3735 | ||
3600 | ALLOC_WITH_HRESULT(&fileDataBuffer, len); | 3736 | ALLOC_WITH_HRESULT(&fileDataBuffer, len) |
3601 | use_fileData = true; | 3737 | use_fileData = true; |
3602 | 3738 | ||
3603 | { | 3739 | { |
@@ -3616,7 +3752,7 @@ HRESULT Bench( | |||
3616 | 3752 | ||
3617 | if (name.IsEqualTo("time")) | 3753 | if (name.IsEqualTo("time")) |
3618 | { | 3754 | { |
3619 | RINOK(ParsePropToUInt32(UString(), propVariant, testTimeMs)); | 3755 | RINOK(ParsePropToUInt32(UString(), propVariant, testTimeMs)) |
3620 | needSetComplexity = true; | 3756 | needSetComplexity = true; |
3621 | testTimeMs *= 1000; | 3757 | testTimeMs *= 1000; |
3622 | continue; | 3758 | continue; |
@@ -3624,7 +3760,7 @@ HRESULT Bench( | |||
3624 | 3760 | ||
3625 | if (name.IsEqualTo("timems")) | 3761 | if (name.IsEqualTo("timems")) |
3626 | { | 3762 | { |
3627 | RINOK(ParsePropToUInt32(UString(), propVariant, testTimeMs)); | 3763 | RINOK(ParsePropToUInt32(UString(), propVariant, testTimeMs)) |
3628 | needSetComplexity = true; | 3764 | needSetComplexity = true; |
3629 | continue; | 3765 | continue; |
3630 | } | 3766 | } |
@@ -3632,7 +3768,7 @@ HRESULT Bench( | |||
3632 | if (name.IsEqualTo("tic")) | 3768 | if (name.IsEqualTo("tic")) |
3633 | { | 3769 | { |
3634 | UInt32 v; | 3770 | UInt32 v; |
3635 | RINOK(ParsePropToUInt32(UString(), propVariant, v)); | 3771 | RINOK(ParsePropToUInt32(UString(), propVariant, v)) |
3636 | if (v >= 64) | 3772 | if (v >= 64) |
3637 | return E_INVALIDARG; | 3773 | return E_INVALIDARG; |
3638 | complexInCommands = (UInt64)1 << v; | 3774 | complexInCommands = (UInt64)1 << v; |
@@ -3644,7 +3780,7 @@ HRESULT Bench( | |||
3644 | isFixedDict = true; | 3780 | isFixedDict = true; |
3645 | if (isCurrent_fixedDict || name.IsEqualTo("ds")) | 3781 | if (isCurrent_fixedDict || name.IsEqualTo("ds")) |
3646 | { | 3782 | { |
3647 | RINOK(ParsePropToUInt32(UString(), propVariant, startDicLog)); | 3783 | RINOK(ParsePropToUInt32(UString(), propVariant, startDicLog)) |
3648 | if (startDicLog > 32) | 3784 | if (startDicLog > 32) |
3649 | return E_INVALIDARG; | 3785 | return E_INVALIDARG; |
3650 | startDicLog_Defined = true; | 3786 | startDicLog_Defined = true; |
@@ -3653,17 +3789,17 @@ HRESULT Bench( | |||
3653 | 3789 | ||
3654 | if (name.IsEqualTo("mts")) | 3790 | if (name.IsEqualTo("mts")) |
3655 | { | 3791 | { |
3656 | RINOK(ParsePropToUInt32(UString(), propVariant, numThreads_Start)); | 3792 | RINOK(ParsePropToUInt32(UString(), propVariant, numThreads_Start)) |
3657 | continue; | 3793 | continue; |
3658 | } | 3794 | } |
3659 | 3795 | ||
3660 | if (name.IsEqualTo("af")) | 3796 | if (name.IsEqualTo("af")) |
3661 | { | 3797 | { |
3662 | UInt32 bundle; | 3798 | UInt32 bundle; |
3663 | RINOK(ParsePropToUInt32(UString(), propVariant, bundle)); | 3799 | RINOK(ParsePropToUInt32(UString(), propVariant, bundle)) |
3664 | if (bundle > 0 && bundle < numCPUs) | 3800 | if (bundle > 0 && bundle < numCPUs) |
3665 | { | 3801 | { |
3666 | #ifndef _7ZIP_ST | 3802 | #ifndef Z7_ST |
3667 | affinityMode.SetLevels(numCPUs, 2); | 3803 | affinityMode.SetLevels(numCPUs, 2); |
3668 | affinityMode.NumBundleThreads = bundle; | 3804 | affinityMode.NumBundleThreads = bundle; |
3669 | #endif | 3805 | #endif |
@@ -3674,7 +3810,7 @@ HRESULT Bench( | |||
3674 | if (name.IsEqualTo("freq")) | 3810 | if (name.IsEqualTo("freq")) |
3675 | { | 3811 | { |
3676 | UInt32 freq32 = 0; | 3812 | UInt32 freq32 = 0; |
3677 | RINOK(ParsePropToUInt32(UString(), propVariant, freq32)); | 3813 | RINOK(ParsePropToUInt32(UString(), propVariant, freq32)) |
3678 | if (freq32 == 0) | 3814 | if (freq32 == 0) |
3679 | return E_INVALIDARG; | 3815 | return E_INVALIDARG; |
3680 | specifiedFreq = (UInt64)freq32 * 1000000; | 3816 | specifiedFreq = (UInt64)freq32 * 1000000; |
@@ -3691,7 +3827,7 @@ HRESULT Bench( | |||
3691 | 3827 | ||
3692 | if (name.IsPrefixedBy_Ascii_NoCase("mt")) | 3828 | if (name.IsPrefixedBy_Ascii_NoCase("mt")) |
3693 | { | 3829 | { |
3694 | UString s = name.Ptr(2); | 3830 | const UString s = name.Ptr(2); |
3695 | if (s.IsEqualTo("*") | 3831 | if (s.IsEqualTo("*") |
3696 | || (s.IsEmpty() | 3832 | || (s.IsEmpty() |
3697 | && propVariant.vt == VT_BSTR | 3833 | && propVariant.vt == VT_BSTR |
@@ -3700,13 +3836,13 @@ HRESULT Bench( | |||
3700 | multiThreadTests = true; | 3836 | multiThreadTests = true; |
3701 | continue; | 3837 | continue; |
3702 | } | 3838 | } |
3703 | #ifndef _7ZIP_ST | 3839 | #ifndef Z7_ST |
3704 | RINOK(ParseMtProp(s, propVariant, numCPUs, numThreadsSpecified)); | 3840 | RINOK(ParseMtProp(s, propVariant, numCPUs, numThreadsSpecified)) |
3705 | #endif | 3841 | #endif |
3706 | continue; | 3842 | continue; |
3707 | } | 3843 | } |
3708 | 3844 | ||
3709 | RINOK(method.ParseMethodFromPROPVARIANT(name, propVariant)); | 3845 | RINOK(method.ParseMethodFromPROPVARIANT(name, propVariant)) |
3710 | } | 3846 | } |
3711 | } | 3847 | } |
3712 | 3848 | ||
@@ -3714,13 +3850,13 @@ HRESULT Bench( | |||
3714 | { | 3850 | { |
3715 | AString s; | 3851 | AString s; |
3716 | 3852 | ||
3717 | #ifndef _WIN32 | 3853 | #ifndef _WIN32 |
3718 | s += "Compiler: "; | 3854 | s += "Compiler: "; |
3719 | GetCompiler(s); | 3855 | GetCompiler(s); |
3720 | printCallback->Print(s); | 3856 | printCallback->Print(s); |
3721 | printCallback->NewLine(); | 3857 | printCallback->NewLine(); |
3722 | s.Empty(); | 3858 | s.Empty(); |
3723 | #endif | 3859 | #endif |
3724 | 3860 | ||
3725 | GetSystemInfoText(s); | 3861 | GetSystemInfoText(s); |
3726 | printCallback->Print(s); | 3862 | printCallback->Print(s); |
@@ -3744,7 +3880,7 @@ HRESULT Bench( | |||
3744 | for (int jj = 0;; jj++) | 3880 | for (int jj = 0;; jj++) |
3745 | { | 3881 | { |
3746 | if (printCallback) | 3882 | if (printCallback) |
3747 | RINOK(printCallback->CheckBreak()); | 3883 | RINOK(printCallback->CheckBreak()) |
3748 | 3884 | ||
3749 | UInt64 start = ::GetTimeCount(); | 3885 | UInt64 start = ::GetTimeCount(); |
3750 | UInt32 sum = (UInt32)start; | 3886 | UInt32 sum = (UInt32)start; |
@@ -3776,7 +3912,7 @@ HRESULT Bench( | |||
3776 | } | 3912 | } |
3777 | if (freqCallback) | 3913 | if (freqCallback) |
3778 | { | 3914 | { |
3779 | RINOK(freqCallback->AddCpuFreq(1, hz, kBenchmarkUsageMult)); | 3915 | RINOK(freqCallback->AddCpuFreq(1, hz, kBenchmarkUsageMult)) |
3780 | } | 3916 | } |
3781 | 3917 | ||
3782 | if (jj >= 1) | 3918 | if (jj >= 1) |
@@ -3806,7 +3942,7 @@ HRESULT Bench( | |||
3806 | } | 3942 | } |
3807 | if (freqCallback) | 3943 | if (freqCallback) |
3808 | { | 3944 | { |
3809 | RINOK(freqCallback->FreqsFinished(1)); | 3945 | RINOK(freqCallback->FreqsFinished(1)) |
3810 | } | 3946 | } |
3811 | } | 3947 | } |
3812 | 3948 | ||
@@ -3830,17 +3966,24 @@ HRESULT Bench( | |||
3830 | printCallback->Print(s); | 3966 | printCallback->Print(s); |
3831 | printCallback->Print("T CPU Freq (MHz):"); | 3967 | printCallback->Print("T CPU Freq (MHz):"); |
3832 | } | 3968 | } |
3833 | UInt64 numMilCommands = 1 << 10; | 3969 | UInt64 numMilCommands = 1 << |
3970 | #ifdef _DEBUG | ||
3971 | 7; | ||
3972 | #else | ||
3973 | 10; | ||
3974 | #endif | ||
3975 | |||
3834 | if (specifiedFreq != 0) | 3976 | if (specifiedFreq != 0) |
3835 | { | 3977 | { |
3836 | while (numMilCommands > 1 && specifiedFreq < (numMilCommands * 1000000)) | 3978 | while (numMilCommands > 1 && specifiedFreq < (numMilCommands * 1000000)) |
3837 | numMilCommands >>= 1; | 3979 | numMilCommands >>= 1; |
3838 | } | 3980 | } |
3839 | 3981 | ||
3840 | for (int jj = 0;; jj++) | 3982 | // for (int jj = 0;; jj++) |
3983 | for (;;) | ||
3841 | { | 3984 | { |
3842 | if (printCallback) | 3985 | if (printCallback) |
3843 | RINOK(printCallback->CheckBreak()); | 3986 | RINOK(printCallback->CheckBreak()) |
3844 | 3987 | ||
3845 | { | 3988 | { |
3846 | // PrintLeft(f, "CPU", kFieldSize_Name); | 3989 | // PrintLeft(f, "CPU", kFieldSize_Name); |
@@ -3855,16 +3998,16 @@ HRESULT Bench( | |||
3855 | fb.showFreq = true; | 3998 | fb.showFreq = true; |
3856 | fb.specifiedFreq = 1; | 3999 | fb.specifiedFreq = 1; |
3857 | 4000 | ||
3858 | HRESULT res = fb.FreqBench(NULL /* printCallback */ | 4001 | const HRESULT res = fb.FreqBench(NULL /* printCallback */ |
3859 | #ifndef _7ZIP_ST | 4002 | #ifndef Z7_ST |
3860 | , &affinityMode | 4003 | , &affinityMode |
3861 | #endif | 4004 | #endif |
3862 | ); | 4005 | ); |
3863 | RINOK(res); | 4006 | RINOK(res) |
3864 | 4007 | ||
3865 | if (freqCallback) | 4008 | if (freqCallback) |
3866 | { | 4009 | { |
3867 | RINOK(freqCallback->AddCpuFreq(numThreads, fb.CpuFreqRes, fb.UsageRes)); | 4010 | RINOK(freqCallback->AddCpuFreq(numThreads, fb.CpuFreqRes, fb.UsageRes)) |
3868 | } | 4011 | } |
3869 | 4012 | ||
3870 | if (printCallback) | 4013 | if (printCallback) |
@@ -3889,7 +4032,7 @@ HRESULT Bench( | |||
3889 | } | 4032 | } |
3890 | // if (jj >= 1) | 4033 | // if (jj >= 1) |
3891 | { | 4034 | { |
3892 | bool needStop = (numMilCommands >= (1 << | 4035 | const bool needStop = (numMilCommands >= (1 << |
3893 | #ifdef _DEBUG | 4036 | #ifdef _DEBUG |
3894 | 7 | 4037 | 7 |
3895 | #else | 4038 | #else |
@@ -3903,7 +4046,7 @@ HRESULT Bench( | |||
3903 | } | 4046 | } |
3904 | if (freqCallback) | 4047 | if (freqCallback) |
3905 | { | 4048 | { |
3906 | RINOK(freqCallback->FreqsFinished(numThreads)); | 4049 | RINOK(freqCallback->FreqsFinished(numThreads)) |
3907 | } | 4050 | } |
3908 | } | 4051 | } |
3909 | 4052 | ||
@@ -3923,10 +4066,12 @@ HRESULT Bench( | |||
3923 | UInt64 dict = (UInt64)1 << startDicLog; | 4066 | UInt64 dict = (UInt64)1 << startDicLog; |
3924 | const bool dictIsDefined = (isFixedDict || method.Get_DicSize(dict)); | 4067 | const bool dictIsDefined = (isFixedDict || method.Get_DicSize(dict)); |
3925 | 4068 | ||
3926 | const int level = method.GetLevel(); | 4069 | const unsigned level = method.GetLevel(); |
3927 | 4070 | ||
3928 | if (method.MethodName.IsEmpty()) | 4071 | AString &methodName = method.MethodName; |
3929 | method.MethodName = "LZMA"; | 4072 | const AString original_MethodName = methodName; |
4073 | if (methodName.IsEmpty()) | ||
4074 | methodName = "LZMA"; | ||
3930 | 4075 | ||
3931 | if (benchCallback) | 4076 | if (benchCallback) |
3932 | { | 4077 | { |
@@ -3949,7 +4094,7 @@ HRESULT Bench( | |||
3949 | return MethodBench( | 4094 | return MethodBench( |
3950 | EXTERNAL_CODECS_LOC_VARS | 4095 | EXTERNAL_CODECS_LOC_VARS |
3951 | complexInCommands, | 4096 | complexInCommands, |
3952 | #ifndef _7ZIP_ST | 4097 | #ifndef Z7_ST |
3953 | true, numThreadsSpecified, | 4098 | true, numThreadsSpecified, |
3954 | &affinityMode, | 4099 | &affinityMode, |
3955 | #endif | 4100 | #endif |
@@ -3958,13 +4103,28 @@ HRESULT Bench( | |||
3958 | kOldLzmaDictBits, printCallback, benchCallback, &benchProps); | 4103 | kOldLzmaDictBits, printCallback, benchCallback, &benchProps); |
3959 | } | 4104 | } |
3960 | 4105 | ||
3961 | AString methodName (method.MethodName); | ||
3962 | if (methodName.IsEqualTo_Ascii_NoCase("CRC")) | 4106 | if (methodName.IsEqualTo_Ascii_NoCase("CRC")) |
3963 | methodName = "crc32"; | 4107 | methodName = "crc32"; |
3964 | method.MethodName = methodName; | 4108 | |
3965 | CMethodId hashID; | 4109 | CMethodId hashID; |
3966 | 4110 | const bool isHashMethod = FindHashMethod(EXTERNAL_CODECS_LOC_VARS methodName, hashID); | |
3967 | if (FindHashMethod(EXTERNAL_CODECS_LOC_VARS methodName, hashID)) | 4111 | int codecIndex = -1; |
4112 | bool isFilter = false; | ||
4113 | if (!isHashMethod) | ||
4114 | { | ||
4115 | UInt32 numStreams; | ||
4116 | codecIndex = FindMethod_Index(EXTERNAL_CODECS_LOC_VARS original_MethodName, | ||
4117 | true, // encode | ||
4118 | hashID, numStreams, isFilter); | ||
4119 | // we can allow non filter for BW tests | ||
4120 | if (!isFilter) codecIndex = -1; | ||
4121 | } | ||
4122 | |||
4123 | CBenchCallbackToPrint callback; | ||
4124 | callback.Init(); | ||
4125 | callback._file = printCallback; | ||
4126 | |||
4127 | if (isHashMethod || codecIndex != -1) | ||
3968 | { | 4128 | { |
3969 | if (!printCallback) | 4129 | if (!printCallback) |
3970 | return S_FALSE; | 4130 | return S_FALSE; |
@@ -3981,17 +4141,27 @@ HRESULT Bench( | |||
3981 | dict64 = fileDataBuffer.Size(); | 4141 | dict64 = fileDataBuffer.Size(); |
3982 | } | 4142 | } |
3983 | 4143 | ||
3984 | // methhodName.RemoveChar(L'-'); | 4144 | for (;;) |
3985 | UInt32 complexity = 10000; | 4145 | { |
4146 | const int index = method.FindProp(NCoderPropID::kDictionarySize); | ||
4147 | if (index < 0) | ||
4148 | break; | ||
4149 | method.Props.Delete((unsigned)index); | ||
4150 | } | ||
4151 | |||
4152 | // methodName.RemoveChar(L'-'); | ||
4153 | Int32 complexity = 16 * k_Hash_Complex_Mult; // for unknown hash method | ||
3986 | const UInt32 *checkSum = NULL; | 4154 | const UInt32 *checkSum = NULL; |
4155 | int benchIndex = -1; | ||
4156 | |||
4157 | if (isHashMethod) | ||
3987 | { | 4158 | { |
3988 | unsigned i; | 4159 | for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_Hash); i++) |
3989 | for (i = 0; i < ARRAY_SIZE(g_Hash); i++) | ||
3990 | { | 4160 | { |
3991 | const CBenchHash &h = g_Hash[i]; | 4161 | const CBenchHash &h = g_Hash[i]; |
3992 | AString benchMethod (h.Name); | 4162 | AString benchMethod (h.Name); |
3993 | AString benchProps; | 4163 | AString benchProps; |
3994 | int propPos = benchMethod.Find(':'); | 4164 | const int propPos = benchMethod.Find(':'); |
3995 | if (propPos >= 0) | 4165 | if (propPos >= 0) |
3996 | { | 4166 | { |
3997 | benchProps = benchMethod.Ptr((unsigned)(propPos + 1)); | 4167 | benchProps = benchMethod.Ptr((unsigned)(propPos + 1)); |
@@ -4000,45 +4170,80 @@ HRESULT Bench( | |||
4000 | 4170 | ||
4001 | if (AreSameMethodNames(benchMethod, methodName)) | 4171 | if (AreSameMethodNames(benchMethod, methodName)) |
4002 | { | 4172 | { |
4003 | bool isMainMathed = method.PropsString.IsEmpty(); | ||
4004 | if (isMainMathed) | ||
4005 | isMainMathed = !checkSum | ||
4006 | || (benchMethod.IsEqualTo_Ascii_NoCase("crc32") && benchProps.IsEqualTo_Ascii_NoCase("8")); | ||
4007 | const bool sameProps = method.PropsString.IsEqualTo_Ascii_NoCase(benchProps); | 4173 | const bool sameProps = method.PropsString.IsEqualTo_Ascii_NoCase(benchProps); |
4008 | if (sameProps || isMainMathed) | 4174 | /* |
4175 | bool isMainMethod = method.PropsString.IsEmpty(); | ||
4176 | if (isMainMethod) | ||
4177 | isMainMethod = !checkSum | ||
4178 | || (benchMethod.IsEqualTo_Ascii_NoCase("crc32") && benchProps.IsEqualTo_Ascii_NoCase("8")); | ||
4179 | if (sameProps || isMainMethod) | ||
4180 | */ | ||
4009 | { | 4181 | { |
4010 | complexity = h.Complex; | 4182 | complexity = (Int32)h.Complex; |
4011 | checkSum = &h.CheckSum; | 4183 | checkSum = &h.CheckSum; |
4012 | if (sameProps) | 4184 | if (sameProps) |
4013 | break; | 4185 | break; |
4186 | /* | ||
4187 | if property. is not specified, we use the complexity | ||
4188 | for latest fastest method (crc32:64) | ||
4189 | */ | ||
4014 | } | 4190 | } |
4015 | } | 4191 | } |
4016 | } | 4192 | } |
4017 | if (!checkSum) | 4193 | // if (!checkSum) return E_NOTIMPL; |
4018 | return E_NOTIMPL; | 4194 | } |
4195 | else | ||
4196 | { | ||
4197 | for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_Bench); i++) | ||
4198 | { | ||
4199 | const CBenchMethod &bench = g_Bench[i]; | ||
4200 | AString benchMethod (bench.Name); | ||
4201 | AString benchProps; | ||
4202 | const int propPos = benchMethod.Find(':'); | ||
4203 | if (propPos >= 0) | ||
4204 | { | ||
4205 | benchProps = benchMethod.Ptr((unsigned)(propPos + 1)); | ||
4206 | benchMethod.DeleteFrom((unsigned)propPos); | ||
4207 | } | ||
4208 | |||
4209 | if (AreSameMethodNames(benchMethod, methodName)) | ||
4210 | { | ||
4211 | const bool sameProps = method.PropsString.IsEqualTo_Ascii_NoCase(benchProps); | ||
4212 | // bool isMainMethod = method.PropsString.IsEmpty(); | ||
4213 | // if (sameProps || isMainMethod) | ||
4214 | { | ||
4215 | benchIndex = (int)i; | ||
4216 | if (sameProps) | ||
4217 | break; | ||
4218 | } | ||
4219 | } | ||
4220 | } | ||
4221 | // if (benchIndex < 0) return E_NOTIMPL; | ||
4019 | } | 4222 | } |
4020 | 4223 | ||
4021 | { | 4224 | { |
4022 | UInt64 usage = 1 << 20; | 4225 | /* we count usage only for crc and filter. non-filters are not supported */ |
4226 | UInt64 usage = (1 << 20); | ||
4023 | UInt64 bufSize = dict64; | 4227 | UInt64 bufSize = dict64; |
4228 | UInt32 numBlocks = isHashMethod ? 1 : 3; | ||
4024 | if (use_fileData) | 4229 | if (use_fileData) |
4025 | { | 4230 | { |
4026 | usage += fileDataBuffer.Size(); | 4231 | usage += fileDataBuffer.Size(); |
4027 | if (bufSize > fileDataBuffer.Size()) | 4232 | if (bufSize > fileDataBuffer.Size()) |
4028 | bufSize = fileDataBuffer.Size(); | 4233 | bufSize = fileDataBuffer.Size(); |
4029 | #ifndef _7ZIP_ST | 4234 | if (isHashMethod) |
4030 | if (numThreadsSpecified != 1) | 4235 | { |
4031 | usage += bufSize * numThreadsSpecified * (k_Crc_CreateLocalBuf_For_File ? 1 : 0); | 4236 | numBlocks = 0; |
4032 | #endif | 4237 | #ifndef Z7_ST |
4238 | if (numThreadsSpecified != 1) | ||
4239 | numBlocks = (k_Crc_CreateLocalBuf_For_File ? 1 : 0); | ||
4240 | #endif | ||
4241 | } | ||
4033 | } | 4242 | } |
4034 | else | 4243 | usage += numThreadsSpecified * bufSize * numBlocks; |
4035 | usage += numThreadsSpecified * bufSize; | ||
4036 | Print_Usage_and_Threads(f, usage, numThreadsSpecified); | 4244 | Print_Usage_and_Threads(f, usage, numThreadsSpecified); |
4037 | } | 4245 | } |
4038 | 4246 | ||
4039 | f.NewLine(); | ||
4040 | |||
4041 | const unsigned kFieldSize_CrcSpeed = 7; | ||
4042 | CUIntVector numThreadsVector; | 4247 | CUIntVector numThreadsVector; |
4043 | { | 4248 | { |
4044 | unsigned nt = numThreads_Start; | 4249 | unsigned nt = numThreads_Start; |
@@ -4047,136 +4252,225 @@ HRESULT Bench( | |||
4047 | if (nt > numThreadsSpecified) | 4252 | if (nt > numThreadsSpecified) |
4048 | break; | 4253 | break; |
4049 | numThreadsVector.Add(nt); | 4254 | numThreadsVector.Add(nt); |
4050 | unsigned next = nt * 2; | 4255 | const unsigned next = nt * 2; |
4051 | UInt32 ntHalf= numThreadsSpecified / 2; | 4256 | const UInt32 ntHalf= numThreadsSpecified / 2; |
4052 | if (ntHalf > nt && ntHalf < next) | 4257 | if (ntHalf > nt && ntHalf < next) |
4053 | numThreadsVector.Add(ntHalf); | 4258 | numThreadsVector.Add(ntHalf); |
4054 | if (numThreadsSpecified > nt && numThreadsSpecified < next) | 4259 | if (numThreadsSpecified > nt && numThreadsSpecified < next) |
4055 | numThreadsVector.Add(numThreadsSpecified); | 4260 | numThreadsVector.Add(numThreadsSpecified); |
4056 | nt = next; | 4261 | nt = next; |
4057 | } | 4262 | } |
4263 | } | ||
4264 | |||
4265 | unsigned numColumns = isHashMethod ? 1 : 2; | ||
4266 | CTempValues speedTotals; | ||
4267 | CTempValues usageTotals; | ||
4268 | { | ||
4269 | const unsigned numItems = numThreadsVector.Size() * numColumns; | ||
4270 | speedTotals.Alloc(numItems); | ||
4271 | usageTotals.Alloc(numItems); | ||
4272 | for (unsigned i = 0; i < numItems; i++) | ||
4058 | { | 4273 | { |
4059 | f.NewLine(); | 4274 | speedTotals.Values[i] = 0; |
4060 | f.Print("THRD"); | 4275 | usageTotals.Values[i] = 0; |
4061 | FOR_VECTOR (ti, numThreadsVector) | ||
4062 | { | ||
4063 | PrintNumber(f, numThreadsVector[ti], 1 + kFieldSize_Usage + kFieldSize_CrcSpeed); | ||
4064 | } | ||
4065 | } | 4276 | } |
4277 | } | ||
4278 | |||
4279 | f.NewLine(); | ||
4280 | for (unsigned line = 0; line < 3; line++) | ||
4281 | { | ||
4282 | f.NewLine(); | ||
4283 | f.Print(line == 0 ? "THRD" : line == 1 ? " " : "Size"); | ||
4284 | FOR_VECTOR (ti, numThreadsVector) | ||
4066 | { | 4285 | { |
4067 | f.NewLine(); | 4286 | if (ti != 0) |
4068 | f.Print(" "); | 4287 | Print_Delimiter(f); |
4069 | FOR_VECTOR (ti, numThreadsVector) | 4288 | if (line == 0) |
4070 | { | 4289 | { |
4071 | PrintRight(f, "Usage", kFieldSize_Usage + 1); | 4290 | PrintSpaces(f, (kFieldSize_CrcSpeed + kFieldSize_Usage + 2) * (numColumns - 1)); |
4072 | PrintRight(f, "BW", kFieldSize_CrcSpeed + 1); | 4291 | PrintNumber(f, numThreadsVector[ti], 1 + kFieldSize_Usage + kFieldSize_CrcSpeed); |
4073 | } | 4292 | } |
4074 | } | 4293 | else |
4075 | { | ||
4076 | f.NewLine(); | ||
4077 | f.Print("Size"); | ||
4078 | FOR_VECTOR (ti, numThreadsVector) | ||
4079 | { | 4294 | { |
4080 | PrintRight(f, "%", kFieldSize_Usage + 1); | 4295 | for (unsigned c = 0; c < numColumns; c++) |
4081 | PrintRight(f, "MB/s", kFieldSize_CrcSpeed + 1); | 4296 | { |
4297 | PrintRight(f, line == 1 ? "Usage" : "%", kFieldSize_Usage + 1); | ||
4298 | PrintRight(f, line == 1 ? "BW" : "MB/s", kFieldSize_CrcSpeed + 1); | ||
4299 | } | ||
4082 | } | 4300 | } |
4083 | } | 4301 | } |
4084 | } | 4302 | } |
4085 | |||
4086 | f.NewLine(); | ||
4087 | f.NewLine(); | 4303 | f.NewLine(); |
4088 | 4304 | ||
4089 | CTempValues speedTotals(numThreadsVector.Size()); | ||
4090 | CTempValues usageTotals(numThreadsVector.Size()); | ||
4091 | { | ||
4092 | FOR_VECTOR (ti, numThreadsVector) | ||
4093 | { | ||
4094 | speedTotals.Values[ti] = 0; | ||
4095 | usageTotals.Values[ti] = 0; | ||
4096 | } | ||
4097 | } | ||
4098 | |||
4099 | UInt64 numSteps = 0; | 4305 | UInt64 numSteps = 0; |
4100 | 4306 | ||
4101 | for (UInt32 i = 0; i < numIterations; i++) | 4307 | // for (UInt32 iter = 0; iter < numIterations; iter++) |
4308 | // { | ||
4309 | unsigned pow = 10; // kNumHashDictBits | ||
4310 | if (startDicLog_Defined) | ||
4311 | pow = startDicLog; | ||
4312 | |||
4313 | // #define NUM_SUB_BITS 2 | ||
4314 | // pow <<= NUM_SUB_BITS; | ||
4315 | for (;; pow++) | ||
4102 | { | 4316 | { |
4103 | unsigned pow = 10; // kNumHashDictBits | 4317 | const UInt64 bufSize = (UInt64)1 << pow; |
4104 | if (startDicLog_Defined) | 4318 | // UInt64 bufSize = (UInt64)1 << (pow >> NUM_SUB_BITS); |
4105 | pow = startDicLog; | 4319 | // bufSize += ((UInt64)pow & ((1 << NUM_SUB_BITS) - 1)) << ((pow >> NUM_SUB_BITS) - NUM_SUB_BITS); |
4106 | for (;; pow++) | ||
4107 | { | ||
4108 | const UInt64 bufSize = (UInt64)1 << pow; | ||
4109 | char s[16]; | ||
4110 | ConvertUInt32ToString(pow, s); | ||
4111 | unsigned pos = MyStringLen(s); | ||
4112 | s[pos++] = ':'; | ||
4113 | s[pos++] = ' '; | ||
4114 | s[pos] = 0; | ||
4115 | PrintRight(f, s, 4); | ||
4116 | |||
4117 | size_t dataSize = fileDataBuffer.Size(); | ||
4118 | if (dataSize > bufSize || !use_fileData) | ||
4119 | dataSize = (size_t)bufSize; | ||
4120 | 4320 | ||
4321 | size_t dataSize = fileDataBuffer.Size(); | ||
4322 | if (dataSize > bufSize || !use_fileData) | ||
4323 | dataSize = (size_t)bufSize; | ||
4324 | |||
4325 | for (UInt32 iter = 0; iter < numIterations; iter++) | ||
4326 | { | ||
4327 | Print_Pow(f, pow); | ||
4328 | // PrintNumber(f, bufSize >> 10, 4); | ||
4329 | |||
4121 | FOR_VECTOR (ti, numThreadsVector) | 4330 | FOR_VECTOR (ti, numThreadsVector) |
4122 | { | 4331 | { |
4123 | RINOK(f.CheckBreak()); | 4332 | RINOK(f.CheckBreak()) |
4124 | const UInt32 t = numThreadsVector[ti]; | 4333 | const UInt32 numThreads = numThreadsVector[ti]; |
4125 | UInt64 speed = 0; | 4334 | if (isHashMethod) |
4126 | UInt64 usage = 0; | 4335 | { |
4127 | 4336 | UInt64 speed = 0; | |
4128 | HRESULT res = CrcBench(EXTERNAL_CODECS_LOC_VARS complexInCommands, | 4337 | UInt64 usage = 0; |
4129 | t, | 4338 | const HRESULT res = CrcBench(EXTERNAL_CODECS_LOC_VARS complexInCommands, |
4339 | numThreads, | ||
4130 | dataSize, (const Byte *)fileDataBuffer, | 4340 | dataSize, (const Byte *)fileDataBuffer, |
4131 | speed, usage, | 4341 | speed, usage, |
4132 | complexity, | 4342 | (UInt32)complexity, |
4133 | 1, // benchWeight, | 4343 | 1, // benchWeight, |
4134 | (pow == kNumHashDictBits && !use_fileData) ? checkSum : NULL, | 4344 | (pow == kNumHashDictBits && !use_fileData) ? checkSum : NULL, |
4135 | method, | 4345 | method, |
4136 | &f, | 4346 | &f, |
4137 | #ifndef _7ZIP_ST | 4347 | #ifndef Z7_ST |
4138 | &affinityMode, | 4348 | &affinityMode, |
4139 | #endif | 4349 | #endif |
4140 | false, // showRating | 4350 | false, // showRating |
4141 | NULL, false, 0); | 4351 | NULL, false, 0); |
4142 | 4352 | RINOK(res) | |
4143 | RINOK(res); | 4353 | |
4144 | 4354 | if (ti != 0) | |
4145 | PrintUsage(f, usage, kFieldSize_Usage); | 4355 | Print_Delimiter(f); |
4146 | PrintNumber(f, speed / 1000000, kFieldSize_CrcSpeed); | 4356 | |
4147 | speedTotals.Values[ti] += speed; | 4357 | Bench_BW_Print_Usage_Speed(f, usage, speed); |
4148 | usageTotals.Values[ti] += usage; | 4358 | speedTotals.Values[ti] += speed; |
4359 | usageTotals.Values[ti] += usage; | ||
4360 | } | ||
4361 | else | ||
4362 | { | ||
4363 | { | ||
4364 | unsigned keySize = 32; | ||
4365 | if (IsString1PrefixedByString2(methodName, "AES128")) keySize = 16; | ||
4366 | else if (IsString1PrefixedByString2(methodName, "AES192")) keySize = 24; | ||
4367 | callback.BenchProps.KeySize = keySize; | ||
4368 | } | ||
4369 | |||
4370 | COneMethodInfo method2 = method; | ||
4371 | unsigned bench_DictBits; | ||
4372 | |||
4373 | if (benchIndex >= 0) | ||
4374 | { | ||
4375 | const CBenchMethod &bench = g_Bench[benchIndex]; | ||
4376 | callback.BenchProps.EncComplex = bench.EncComplex; | ||
4377 | callback.BenchProps.DecComplexUnc = bench.DecComplexUnc; | ||
4378 | callback.BenchProps.DecComplexCompr = bench.DecComplexCompr; | ||
4379 | bench_DictBits = bench.DictBits; | ||
4380 | // bench_DictBits = kOldLzmaDictBits; = 32 default : for debug | ||
4381 | } | ||
4382 | else | ||
4383 | { | ||
4384 | bench_DictBits = kOldLzmaDictBits; // = 32 default | ||
4385 | if (isFilter) | ||
4386 | { | ||
4387 | const unsigned k_UnknownCoderComplexity = 4; | ||
4388 | callback.BenchProps.EncComplex = k_UnknownCoderComplexity; | ||
4389 | callback.BenchProps.DecComplexUnc = k_UnknownCoderComplexity; | ||
4390 | } | ||
4391 | else | ||
4392 | { | ||
4393 | callback.BenchProps.EncComplex = 1 << 10; | ||
4394 | callback.BenchProps.DecComplexUnc = 1 << 6; | ||
4395 | } | ||
4396 | callback.BenchProps.DecComplexCompr = 0; | ||
4397 | } | ||
4398 | callback.NeedPrint = false; | ||
4399 | |||
4400 | if (StringsAreEqualNoCase_Ascii(method2.MethodName, "LZMA")) | ||
4401 | { | ||
4402 | const NCOM::CPropVariant propVariant = (UInt32)pow; | ||
4403 | RINOK(method2.ParseMethodFromPROPVARIANT((UString)"d", propVariant)) | ||
4404 | } | ||
4405 | |||
4406 | const HRESULT res = MethodBench( | ||
4407 | EXTERNAL_CODECS_LOC_VARS | ||
4408 | complexInCommands, | ||
4409 | #ifndef Z7_ST | ||
4410 | false, // oldLzmaBenchMode | ||
4411 | numThreadsVector[ti], | ||
4412 | &affinityMode, | ||
4413 | #endif | ||
4414 | method2, | ||
4415 | dataSize, (const Byte *)fileDataBuffer, | ||
4416 | bench_DictBits, | ||
4417 | printCallback, | ||
4418 | &callback, | ||
4419 | &callback.BenchProps); | ||
4420 | RINOK(res) | ||
4421 | |||
4422 | if (ti != 0) | ||
4423 | Print_Delimiter(f); | ||
4424 | |||
4425 | for (unsigned i = 0; i < 2; i++) | ||
4426 | { | ||
4427 | const CBenchInfo &bi = callback.BenchInfo_Results[i]; | ||
4428 | const UInt64 usage = bi.GetUsage(); | ||
4429 | const UInt64 speed = bi.GetUnpackSizeSpeed(); | ||
4430 | usageTotals.Values[ti * 2 + i] += usage; | ||
4431 | speedTotals.Values[ti * 2 + i] += speed; | ||
4432 | Bench_BW_Print_Usage_Speed(f, usage, speed); | ||
4433 | } | ||
4434 | } | ||
4149 | } | 4435 | } |
4150 | 4436 | ||
4151 | f.NewLine(); | 4437 | f.NewLine(); |
4152 | numSteps++; | 4438 | numSteps++; |
4153 | if (dataSize >= dict64) | ||
4154 | break; | ||
4155 | } | 4439 | } |
4440 | if (dataSize >= dict64) | ||
4441 | break; | ||
4156 | } | 4442 | } |
4443 | |||
4157 | if (numSteps != 0) | 4444 | if (numSteps != 0) |
4158 | { | 4445 | { |
4159 | f.NewLine(); | ||
4160 | f.Print("Avg:"); | 4446 | f.Print("Avg:"); |
4161 | for (unsigned ti = 0; ti < numThreadsVector.Size(); ti++) | 4447 | for (unsigned ti = 0; ti < numThreadsVector.Size(); ti++) |
4162 | { | 4448 | { |
4163 | PrintUsage(f, usageTotals.Values[ti] / numSteps, kFieldSize_Usage); | 4449 | if (ti != 0) |
4164 | PrintNumber(f, speedTotals.Values[ti] / numSteps / 1000000, kFieldSize_CrcSpeed); | 4450 | Print_Delimiter(f); |
4451 | for (unsigned i = 0; i < numColumns; i++) | ||
4452 | Bench_BW_Print_Usage_Speed(f, | ||
4453 | usageTotals.Values[ti * numColumns + i] / numSteps, | ||
4454 | speedTotals.Values[ti * numColumns + i] / numSteps); | ||
4165 | } | 4455 | } |
4166 | f.NewLine(); | 4456 | f.NewLine(); |
4167 | } | 4457 | } |
4458 | |||
4168 | return S_OK; | 4459 | return S_OK; |
4169 | } | 4460 | } |
4170 | 4461 | ||
4171 | bool use2Columns = false; | 4462 | bool use2Columns = false; |
4172 | 4463 | ||
4173 | bool totalBenchMode = (method.MethodName.IsEqualTo_Ascii_NoCase("*")); | 4464 | bool totalBenchMode = false; |
4174 | bool onlyHashBench = false; | 4465 | bool onlyHashBench = false; |
4175 | if (method.MethodName.IsEqualTo_Ascii_NoCase("hash")) | 4466 | if (methodName.IsEqualTo_Ascii_NoCase("hash")) |
4176 | { | 4467 | { |
4177 | onlyHashBench = true; | 4468 | onlyHashBench = true; |
4469 | methodName = "*"; | ||
4178 | totalBenchMode = true; | 4470 | totalBenchMode = true; |
4179 | } | 4471 | } |
4472 | else if (methodName.Find('*') >= 0) | ||
4473 | totalBenchMode = true; | ||
4180 | 4474 | ||
4181 | // ---------- Threads loop ---------- | 4475 | // ---------- Threads loop ---------- |
4182 | for (unsigned threadsPassIndex = 0; threadsPassIndex < 3; threadsPassIndex++) | 4476 | for (unsigned threadsPassIndex = 0; threadsPassIndex < 3; threadsPassIndex++) |
@@ -4207,10 +4501,6 @@ HRESULT Bench( | |||
4207 | } | 4501 | } |
4208 | } | 4502 | } |
4209 | 4503 | ||
4210 | CBenchCallbackToPrint callback; | ||
4211 | callback.Init(); | ||
4212 | callback._file = printCallback; | ||
4213 | |||
4214 | IBenchPrintCallback &f = *printCallback; | 4504 | IBenchPrintCallback &f = *printCallback; |
4215 | 4505 | ||
4216 | if (threadsPassIndex > 0) | 4506 | if (threadsPassIndex > 0) |
@@ -4230,7 +4520,7 @@ HRESULT Bench( | |||
4230 | 4520 | ||
4231 | if (ramSize_Defined) | 4521 | if (ramSize_Defined) |
4232 | for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--) | 4522 | for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--) |
4233 | if (GetBenchMemoryUsage(numThreads, level, ((UInt64)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize) | 4523 | if (GetBenchMemoryUsage(numThreads, (int)level, ((UInt64)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize) |
4234 | break; | 4524 | break; |
4235 | 4525 | ||
4236 | dict = (UInt64)1 << dicSizeLog; | 4526 | dict = (UInt64)1 << dicSizeLog; |
@@ -4246,7 +4536,7 @@ HRESULT Bench( | |||
4246 | Print_Usage_and_Threads(f, | 4536 | Print_Usage_and_Threads(f, |
4247 | onlyHashBench ? | 4537 | onlyHashBench ? |
4248 | GetBenchMemoryUsage_Hash(numThreads, dict) : | 4538 | GetBenchMemoryUsage_Hash(numThreads, dict) : |
4249 | GetBenchMemoryUsage(numThreads, level, dict, totalBenchMode), | 4539 | GetBenchMemoryUsage(numThreads, (int)level, dict, totalBenchMode), |
4250 | numThreads); | 4540 | numThreads); |
4251 | 4541 | ||
4252 | f.NewLine(); | 4542 | f.NewLine(); |
@@ -4355,12 +4645,12 @@ HRESULT Bench( | |||
4355 | fb.showFreq = (freqTest == kNumCpuTests - 1 || specifiedFreq != 0); | 4645 | fb.showFreq = (freqTest == kNumCpuTests - 1 || specifiedFreq != 0); |
4356 | fb.specifiedFreq = specifiedFreq; | 4646 | fb.specifiedFreq = specifiedFreq; |
4357 | 4647 | ||
4358 | HRESULT res = fb.FreqBench(printCallback | 4648 | const HRESULT res = fb.FreqBench(printCallback |
4359 | #ifndef _7ZIP_ST | 4649 | #ifndef Z7_ST |
4360 | , &affinityMode | 4650 | , &affinityMode |
4361 | #endif | 4651 | #endif |
4362 | ); | 4652 | ); |
4363 | RINOK(res); | 4653 | RINOK(res) |
4364 | 4654 | ||
4365 | cpuFreq = fb.CpuFreqRes; | 4655 | cpuFreq = fb.CpuFreqRes; |
4366 | callback.NewLine(); | 4656 | callback.NewLine(); |
@@ -4390,9 +4680,9 @@ HRESULT Bench( | |||
4390 | dataSize = (size_t)dict; | 4680 | dataSize = (size_t)dict; |
4391 | } | 4681 | } |
4392 | 4682 | ||
4393 | HRESULT res = TotalBench(EXTERNAL_CODECS_LOC_VARS | 4683 | const HRESULT res = TotalBench(EXTERNAL_CODECS_LOC_VARS |
4394 | complexInCommands, | 4684 | method, complexInCommands, |
4395 | #ifndef _7ZIP_ST | 4685 | #ifndef Z7_ST |
4396 | numThreads, | 4686 | numThreads, |
4397 | &affinityMode, | 4687 | &affinityMode, |
4398 | #endif | 4688 | #endif |
@@ -4400,7 +4690,7 @@ HRESULT Bench( | |||
4400 | dataSize, | 4690 | dataSize, |
4401 | (const Byte *)fileDataBuffer, | 4691 | (const Byte *)fileDataBuffer, |
4402 | printCallback, &callback); | 4692 | printCallback, &callback); |
4403 | RINOK(res); | 4693 | RINOK(res) |
4404 | } | 4694 | } |
4405 | 4695 | ||
4406 | { | 4696 | { |
@@ -4418,14 +4708,16 @@ HRESULT Bench( | |||
4418 | dataSize = (size_t)dict; | 4708 | dataSize = (size_t)dict; |
4419 | } | 4709 | } |
4420 | 4710 | ||
4421 | HRESULT res = TotalBench_Hash(EXTERNAL_CODECS_LOC_VARS complexInCommands, numThreads, | 4711 | const HRESULT res = TotalBench_Hash(EXTERNAL_CODECS_LOC_VARS |
4712 | method, complexInCommands, | ||
4713 | numThreads, | ||
4422 | dataSize, (const Byte *)fileDataBuffer, | 4714 | dataSize, (const Byte *)fileDataBuffer, |
4423 | printCallback, &callback, | 4715 | printCallback, &callback, |
4424 | #ifndef _7ZIP_ST | 4716 | #ifndef Z7_ST |
4425 | &affinityMode, | 4717 | &affinityMode, |
4426 | #endif | 4718 | #endif |
4427 | &callback.EncodeRes, true, cpuFreq); | 4719 | &callback.EncodeRes, true, cpuFreq); |
4428 | RINOK(res); | 4720 | RINOK(res) |
4429 | } | 4721 | } |
4430 | 4722 | ||
4431 | callback.NewLine(); | 4723 | callback.NewLine(); |
@@ -4439,12 +4731,12 @@ HRESULT Bench( | |||
4439 | fb.showFreq = (specifiedFreq != 0); | 4731 | fb.showFreq = (specifiedFreq != 0); |
4440 | fb.specifiedFreq = specifiedFreq; | 4732 | fb.specifiedFreq = specifiedFreq; |
4441 | 4733 | ||
4442 | HRESULT res = fb.FreqBench(printCallback | 4734 | const HRESULT res = fb.FreqBench(printCallback |
4443 | #ifndef _7ZIP_ST | 4735 | #ifndef Z7_ST |
4444 | , &affinityMode | 4736 | , &affinityMode |
4445 | #endif | 4737 | #endif |
4446 | ); | 4738 | ); |
4447 | RINOK(res); | 4739 | RINOK(res) |
4448 | callback.NewLine(); | 4740 | callback.NewLine(); |
4449 | } | 4741 | } |
4450 | } | 4742 | } |
@@ -4455,12 +4747,12 @@ HRESULT Bench( | |||
4455 | if (!methodName.IsEqualTo_Ascii_NoCase("LZMA")) | 4747 | if (!methodName.IsEqualTo_Ascii_NoCase("LZMA")) |
4456 | { | 4748 | { |
4457 | unsigned i; | 4749 | unsigned i; |
4458 | for (i = 0; i < ARRAY_SIZE(g_Bench); i++) | 4750 | for (i = 0; i < Z7_ARRAY_SIZE(g_Bench); i++) |
4459 | { | 4751 | { |
4460 | const CBenchMethod &h = g_Bench[i]; | 4752 | const CBenchMethod &h = g_Bench[i]; |
4461 | AString benchMethod (h.Name); | 4753 | AString benchMethod (h.Name); |
4462 | AString benchProps; | 4754 | AString benchProps; |
4463 | int propPos = benchMethod.Find(':'); | 4755 | const int propPos = benchMethod.Find(':'); |
4464 | if (propPos >= 0) | 4756 | if (propPos >= 0) |
4465 | { | 4757 | { |
4466 | benchProps = benchMethod.Ptr((unsigned)(propPos + 1)); | 4758 | benchProps = benchMethod.Ptr((unsigned)(propPos + 1)); |
@@ -4475,14 +4767,16 @@ HRESULT Bench( | |||
4475 | { | 4767 | { |
4476 | callback.BenchProps.EncComplex = h.EncComplex; | 4768 | callback.BenchProps.EncComplex = h.EncComplex; |
4477 | callback.BenchProps.DecComplexCompr = h.DecComplexCompr; | 4769 | callback.BenchProps.DecComplexCompr = h.DecComplexCompr; |
4478 | callback.BenchProps.DecComplexUnc = h.DecComplexUnc;; | 4770 | callback.BenchProps.DecComplexUnc = h.DecComplexUnc; |
4479 | needSetComplexity = false; | 4771 | needSetComplexity = false; |
4480 | break; | 4772 | break; |
4481 | } | 4773 | } |
4482 | } | 4774 | } |
4483 | } | 4775 | } |
4484 | if (i == ARRAY_SIZE(g_Bench)) | 4776 | /* |
4777 | if (i == Z7_ARRAY_SIZE(g_Bench)) | ||
4485 | return E_NOTIMPL; | 4778 | return E_NOTIMPL; |
4779 | */ | ||
4486 | } | 4780 | } |
4487 | if (needSetComplexity) | 4781 | if (needSetComplexity) |
4488 | callback.BenchProps.SetLzmaCompexity(); | 4782 | callback.BenchProps.SetLzmaCompexity(); |
@@ -4499,12 +4793,7 @@ HRESULT Bench( | |||
4499 | pow--; | 4793 | pow--; |
4500 | for (; GetDictSizeFromLog(pow) <= dict; pow++) | 4794 | for (; GetDictSizeFromLog(pow) <= dict; pow++) |
4501 | { | 4795 | { |
4502 | char s[16]; | 4796 | Print_Pow(f, pow); |
4503 | ConvertUInt32ToString(pow, s); | ||
4504 | unsigned pos = MyStringLen(s); | ||
4505 | s[pos++] = ':'; | ||
4506 | s[pos] = 0; | ||
4507 | PrintLeft(f, s, kFieldSize_SmallName); | ||
4508 | callback.DictSize = (UInt64)1 << pow; | 4797 | callback.DictSize = (UInt64)1 << pow; |
4509 | 4798 | ||
4510 | COneMethodInfo method2 = method; | 4799 | COneMethodInfo method2 = method; |
@@ -4515,7 +4804,7 @@ HRESULT Bench( | |||
4515 | // method2 can have two different dictionary size properties. | 4804 | // method2 can have two different dictionary size properties. |
4516 | // And last property is main. | 4805 | // And last property is main. |
4517 | NCOM::CPropVariant propVariant = (UInt32)pow; | 4806 | NCOM::CPropVariant propVariant = (UInt32)pow; |
4518 | RINOK(method2.ParseMethodFromPROPVARIANT((UString)"d", propVariant)); | 4807 | RINOK(method2.ParseMethodFromPROPVARIANT((UString)"d", propVariant)) |
4519 | } | 4808 | } |
4520 | 4809 | ||
4521 | size_t uncompressedDataSize; | 4810 | size_t uncompressedDataSize; |
@@ -4532,10 +4821,10 @@ HRESULT Bench( | |||
4532 | uncompressedDataSize += kAdditionalSize; | 4821 | uncompressedDataSize += kAdditionalSize; |
4533 | } | 4822 | } |
4534 | 4823 | ||
4535 | HRESULT res = MethodBench( | 4824 | const HRESULT res = MethodBench( |
4536 | EXTERNAL_CODECS_LOC_VARS | 4825 | EXTERNAL_CODECS_LOC_VARS |
4537 | complexInCommands, | 4826 | complexInCommands, |
4538 | #ifndef _7ZIP_ST | 4827 | #ifndef Z7_ST |
4539 | true, numThreads, | 4828 | true, numThreads, |
4540 | &affinityMode, | 4829 | &affinityMode, |
4541 | #endif | 4830 | #endif |
@@ -4543,7 +4832,7 @@ HRESULT Bench( | |||
4543 | uncompressedDataSize, (const Byte *)fileDataBuffer, | 4832 | uncompressedDataSize, (const Byte *)fileDataBuffer, |
4544 | kOldLzmaDictBits, printCallback, &callback, &callback.BenchProps); | 4833 | kOldLzmaDictBits, printCallback, &callback, &callback.BenchProps); |
4545 | f.NewLine(); | 4834 | f.NewLine(); |
4546 | RINOK(res); | 4835 | RINOK(res) |
4547 | if (!multiDict) | 4836 | if (!multiDict) |
4548 | break; | 4837 | break; |
4549 | } | 4838 | } |
diff --git a/CPP/7zip/UI/Common/Bench.h b/CPP/7zip/UI/Common/Bench.h index ab0c304..313676d 100644 --- a/CPP/7zip/UI/Common/Bench.h +++ b/CPP/7zip/UI/Common/Bench.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // Bench.h | 1 | // Bench.h |
2 | 2 | ||
3 | #ifndef __7ZIP_BENCH_H | 3 | #ifndef ZIP7_INC_7ZIP_BENCH_H |
4 | #define __7ZIP_BENCH_H | 4 | #define ZIP7_INC_7ZIP_BENCH_H |
5 | 5 | ||
6 | #include "../../../Windows/System.h" | 6 | #include "../../../Windows/System.h" |
7 | 7 | ||
@@ -71,32 +71,31 @@ struct CTotalBenchRes | |||
71 | }; | 71 | }; |
72 | 72 | ||
73 | 73 | ||
74 | const unsigned kBenchMinDicLogSize = 18; | ||
75 | |||
76 | UInt64 GetBenchMemoryUsage(UInt32 numThreads, int level, UInt64 dictionary, bool totalBench); | ||
74 | 77 | ||
75 | struct IBenchCallback | 78 | Z7_PURE_INTERFACES_BEGIN |
79 | DECLARE_INTERFACE(IBenchCallback) | ||
76 | { | 80 | { |
77 | // virtual HRESULT SetFreq(bool showFreq, UInt64 cpuFreq) = 0; | 81 | // virtual HRESULT SetFreq(bool showFreq, UInt64 cpuFreq) = 0; |
78 | virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0; | 82 | virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0; |
79 | virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0; | 83 | virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0; |
80 | }; | 84 | }; |
81 | 85 | ||
82 | 86 | DECLARE_INTERFACE(IBenchPrintCallback) | |
83 | |||
84 | const unsigned kBenchMinDicLogSize = 18; | ||
85 | |||
86 | UInt64 GetBenchMemoryUsage(UInt32 numThreads, int level, UInt64 dictionary, bool totalBench); | ||
87 | |||
88 | struct IBenchPrintCallback | ||
89 | { | 87 | { |
90 | virtual void Print(const char *s) = 0; | 88 | virtual void Print(const char *s) = 0; |
91 | virtual void NewLine() = 0; | 89 | virtual void NewLine() = 0; |
92 | virtual HRESULT CheckBreak() = 0; | 90 | virtual HRESULT CheckBreak() = 0; |
93 | }; | 91 | }; |
94 | 92 | ||
95 | struct IBenchFreqCallback | 93 | DECLARE_INTERFACE(IBenchFreqCallback) |
96 | { | 94 | { |
97 | virtual HRESULT AddCpuFreq(unsigned numThreads, UInt64 freq, UInt64 usage) = 0; | 95 | virtual HRESULT AddCpuFreq(unsigned numThreads, UInt64 freq, UInt64 usage) = 0; |
98 | virtual HRESULT FreqsFinished(unsigned numThreads) = 0; | 96 | virtual HRESULT FreqsFinished(unsigned numThreads) = 0; |
99 | }; | 97 | }; |
98 | Z7_PURE_INTERFACES_END | ||
100 | 99 | ||
101 | HRESULT Bench( | 100 | HRESULT Bench( |
102 | DECL_EXTERNAL_CODECS_LOC_VARS | 101 | DECL_EXTERNAL_CODECS_LOC_VARS |
@@ -113,7 +112,7 @@ void GetSysInfo(AString &s1, AString &s2); | |||
113 | void GetCpuName(AString &s); | 112 | void GetCpuName(AString &s); |
114 | void AddCpuFeatures(AString &s); | 113 | void AddCpuFeatures(AString &s); |
115 | 114 | ||
116 | #ifdef _7ZIP_LARGE_PAGES | 115 | #ifdef Z7_LARGE_PAGES |
117 | void Add_LargePages_String(AString &s); | 116 | void Add_LargePages_String(AString &s); |
118 | #else | 117 | #else |
119 | // #define Add_LargePages_String | 118 | // #define Add_LargePages_String |
diff --git a/CPP/7zip/UI/Common/CompressCall.cpp b/CPP/7zip/UI/Common/CompressCall.cpp index 3ef047f..42bae2a 100644 --- a/CPP/7zip/UI/Common/CompressCall.cpp +++ b/CPP/7zip/UI/Common/CompressCall.cpp | |||
@@ -83,7 +83,7 @@ static HRESULT Call7zGui(const UString ¶ms, | |||
83 | const WRes wres = process.Create(imageName, params, NULL); // curDir); | 83 | const WRes wres = process.Create(imageName, params, NULL); // curDir); |
84 | if (wres != 0) | 84 | if (wres != 0) |
85 | { | 85 | { |
86 | HRESULT hres = HRESULT_FROM_WIN32(wres); | 86 | const HRESULT hres = HRESULT_FROM_WIN32(wres); |
87 | ErrorMessageHRESULT(hres, imageName); | 87 | ErrorMessageHRESULT(hres, imageName); |
88 | return hres; | 88 | return hres; |
89 | } | 89 | } |
@@ -92,7 +92,7 @@ static HRESULT Call7zGui(const UString ¶ms, | |||
92 | else if (event != NULL) | 92 | else if (event != NULL) |
93 | { | 93 | { |
94 | HANDLE handles[] = { process, *event }; | 94 | HANDLE handles[] = { process, *event }; |
95 | ::WaitForMultipleObjects(ARRAY_SIZE(handles), handles, FALSE, INFINITE); | 95 | ::WaitForMultipleObjects(Z7_ARRAY_SIZE(handles), handles, FALSE, INFINITE); |
96 | } | 96 | } |
97 | return S_OK; | 97 | return S_OK; |
98 | } | 98 | } |
@@ -175,7 +175,7 @@ static HRESULT CreateMap(const UStringVector &names, | |||
175 | FOR_VECTOR (i, names) | 175 | FOR_VECTOR (i, names) |
176 | { | 176 | { |
177 | const UString &s = names[i]; | 177 | const UString &s = names[i]; |
178 | unsigned len = s.Len() + 1; | 178 | const unsigned len = s.Len() + 1; |
179 | wmemcpy(cur, (const wchar_t *)s, len); | 179 | wmemcpy(cur, (const wchar_t *)s, len); |
180 | cur += len; | 180 | cur += len; |
181 | } | 181 | } |
@@ -197,7 +197,7 @@ HRESULT CompressFiles( | |||
197 | CFileMapping fileMapping; | 197 | CFileMapping fileMapping; |
198 | NSynchronization::CManualResetEvent event; | 198 | NSynchronization::CManualResetEvent event; |
199 | params += kIncludeSwitch; | 199 | params += kIncludeSwitch; |
200 | RINOK(CreateMap(names, fileMapping, event, params)); | 200 | RINOK(CreateMap(names, fileMapping, event, params)) |
201 | 201 | ||
202 | if (!arcType.IsEmpty()) | 202 | if (!arcType.IsEmpty()) |
203 | { | 203 | { |
@@ -336,7 +336,7 @@ void Benchmark(bool totalMode) | |||
336 | if (totalMode) | 336 | if (totalMode) |
337 | params += " -mm=*"; | 337 | params += " -mm=*"; |
338 | AddLagePagesSwitch(params); | 338 | AddLagePagesSwitch(params); |
339 | HRESULT result = Call7zGui(params, false, NULL); | 339 | const HRESULT result = Call7zGui(params, false, NULL); |
340 | if (result != S_OK) | 340 | if (result != S_OK) |
341 | ErrorMessageHRESULT(result); | 341 | ErrorMessageHRESULT(result); |
342 | MY_TRY_FINISH_VOID | 342 | MY_TRY_FINISH_VOID |
diff --git a/CPP/7zip/UI/Common/CompressCall.h b/CPP/7zip/UI/Common/CompressCall.h index 2697fda..f2da163 100644 --- a/CPP/7zip/UI/Common/CompressCall.h +++ b/CPP/7zip/UI/Common/CompressCall.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // CompressCall.h | 1 | // CompressCall.h |
2 | 2 | ||
3 | #ifndef __COMPRESS_CALL_H | 3 | #ifndef ZIP7_INC_COMPRESS_CALL_H |
4 | #define __COMPRESS_CALL_H | 4 | #define ZIP7_INC_COMPRESS_CALL_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/CompressCall2.cpp b/CPP/7zip/UI/Common/CompressCall2.cpp index 5d617e1..21eb472 100644 --- a/CPP/7zip/UI/Common/CompressCall2.cpp +++ b/CPP/7zip/UI/Common/CompressCall2.cpp | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | #include "StdAfx.h" | 3 | #include "StdAfx.h" |
4 | 4 | ||
5 | #ifndef Z7_EXTERNAL_CODECS | ||
6 | |||
5 | #include "../../../Common/MyException.h" | 7 | #include "../../../Common/MyException.h" |
6 | 8 | ||
7 | #include "../../UI/Common/EnumDirItems.h" | 9 | #include "../../UI/Common/EnumDirItems.h" |
@@ -33,7 +35,7 @@ static void ThrowException_if_Error(HRESULT res) | |||
33 | throw CSystemException(res); | 35 | throw CSystemException(res); |
34 | } | 36 | } |
35 | 37 | ||
36 | #ifdef EXTERNAL_CODECS | 38 | #ifdef Z7_EXTERNAL_CODECS |
37 | 39 | ||
38 | #define CREATE_CODECS \ | 40 | #define CREATE_CODECS \ |
39 | CCodecs *codecs = new CCodecs; \ | 41 | CCodecs *codecs = new CCodecs; \ |
@@ -42,10 +44,10 @@ static void ThrowException_if_Error(HRESULT res) | |||
42 | Codecs_AddHashArcHandler(codecs); | 44 | Codecs_AddHashArcHandler(codecs); |
43 | 45 | ||
44 | #define LOAD_EXTERNAL_CODECS \ | 46 | #define LOAD_EXTERNAL_CODECS \ |
45 | CExternalCodecs __externalCodecs; \ | 47 | CExternalCodecs _externalCodecs; \ |
46 | __externalCodecs.GetCodecs = codecs; \ | 48 | _externalCodecs.GetCodecs = codecs; \ |
47 | __externalCodecs.GetHashers = codecs; \ | 49 | _externalCodecs.GetHashers = codecs; \ |
48 | ThrowException_if_Error(__externalCodecs.Load()); | 50 | ThrowException_if_Error(_externalCodecs.Load()); |
49 | 51 | ||
50 | #else | 52 | #else |
51 | 53 | ||
@@ -321,3 +323,5 @@ void Benchmark(bool totalMode) | |||
321 | 323 | ||
322 | MY_TRY_FINISH | 324 | MY_TRY_FINISH |
323 | } | 325 | } |
326 | |||
327 | #endif | ||
diff --git a/CPP/7zip/UI/Common/DefaultName.h b/CPP/7zip/UI/Common/DefaultName.h index df16456..46f6e9e 100644 --- a/CPP/7zip/UI/Common/DefaultName.h +++ b/CPP/7zip/UI/Common/DefaultName.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // DefaultName.h | 1 | // DefaultName.h |
2 | 2 | ||
3 | #ifndef __DEFAULT_NAME_H | 3 | #ifndef ZIP7_INC_DEFAULT_NAME_H |
4 | #define __DEFAULT_NAME_H | 4 | #define ZIP7_INC_DEFAULT_NAME_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/DirItem.h b/CPP/7zip/UI/Common/DirItem.h index 86e385f..ae84937 100644 --- a/CPP/7zip/UI/Common/DirItem.h +++ b/CPP/7zip/UI/Common/DirItem.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // DirItem.h | 1 | // DirItem.h |
2 | 2 | ||
3 | #ifndef __DIR_ITEM_H | 3 | #ifndef ZIP7_INC_DIR_ITEM_H |
4 | #define __DIR_ITEM_H | 4 | #define ZIP7_INC_DIR_ITEM_H |
5 | 5 | ||
6 | #ifdef _WIN32 | 6 | #ifdef _WIN32 |
7 | #include "../../../Common/MyLinux.h" | 7 | #include "../../../Common/MyLinux.h" |
@@ -72,15 +72,15 @@ struct CDirItemsStat2: public CDirItemsStat | |||
72 | }; | 72 | }; |
73 | 73 | ||
74 | 74 | ||
75 | Z7_PURE_INTERFACES_BEGIN | ||
75 | 76 | ||
76 | #define INTERFACE_IDirItemsCallback(x) \ | 77 | #define Z7_IFACEN_IDirItemsCallback(x) \ |
77 | virtual HRESULT ScanError(const FString &path, DWORD systemError) x; \ | 78 | virtual HRESULT ScanError(const FString &path, DWORD systemError) x \ |
78 | virtual HRESULT ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir) x; \ | 79 | virtual HRESULT ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir) x \ |
79 | 80 | ||
80 | struct IDirItemsCallback | 81 | Z7_IFACE_DECL_PURE(IDirItemsCallback) |
81 | { | 82 | |
82 | INTERFACE_IDirItemsCallback(=0) | 83 | Z7_PURE_INTERFACES_END |
83 | }; | ||
84 | 84 | ||
85 | 85 | ||
86 | struct CArcTime | 86 | struct CArcTime |
diff --git a/CPP/7zip/UI/Common/EnumDirItems.cpp b/CPP/7zip/UI/Common/EnumDirItems.cpp index dab3725..d536c47 100644 --- a/CPP/7zip/UI/Common/EnumDirItems.cpp +++ b/CPP/7zip/UI/Common/EnumDirItems.cpp | |||
@@ -18,7 +18,7 @@ | |||
18 | #include "../../../Windows/FileName.h" | 18 | #include "../../../Windows/FileName.h" |
19 | 19 | ||
20 | #if defined(_WIN32) && !defined(UNDER_CE) | 20 | #if defined(_WIN32) && !defined(UNDER_CE) |
21 | #define _USE_SECURITY_CODE | 21 | #define Z7_USE_SECURITY_CODE |
22 | #include "../../../Windows/SecurityUtils.h" | 22 | #include "../../../Windows/SecurityUtils.h" |
23 | #endif | 23 | #endif |
24 | 24 | ||
@@ -183,7 +183,7 @@ CDirItems::CDirItems(): | |||
183 | , ExcludeDirItems(false) | 183 | , ExcludeDirItems(false) |
184 | , ExcludeFileItems(false) | 184 | , ExcludeFileItems(false) |
185 | , ShareForWrite(false) | 185 | , ShareForWrite(false) |
186 | #ifdef _USE_SECURITY_CODE | 186 | #ifdef Z7_USE_SECURITY_CODE |
187 | , ReadSecure(false) | 187 | , ReadSecure(false) |
188 | #endif | 188 | #endif |
189 | #ifndef _WIN32 | 189 | #ifndef _WIN32 |
@@ -191,13 +191,13 @@ CDirItems::CDirItems(): | |||
191 | #endif | 191 | #endif |
192 | , Callback(NULL) | 192 | , Callback(NULL) |
193 | { | 193 | { |
194 | #ifdef _USE_SECURITY_CODE | 194 | #ifdef Z7_USE_SECURITY_CODE |
195 | _saclEnabled = InitLocalPrivileges(); | 195 | _saclEnabled = InitLocalPrivileges(); |
196 | #endif | 196 | #endif |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | #ifdef _USE_SECURITY_CODE | 200 | #ifdef Z7_USE_SECURITY_CODE |
201 | 201 | ||
202 | HRESULT CDirItems::AddSecurityItem(const FString &path, int &secureIndex) | 202 | HRESULT CDirItems::AddSecurityItem(const FString &path, int &secureIndex) |
203 | { | 203 | { |
@@ -236,7 +236,7 @@ HRESULT CDirItems::AddSecurityItem(const FString &path, int &secureIndex) | |||
236 | if (res) | 236 | if (res) |
237 | { | 237 | { |
238 | if (secureSize != TempSecureBuf.Size()) | 238 | if (secureSize != TempSecureBuf.Size()) |
239 | errorCode = ERROR_INVALID_FUNCTION;; | 239 | errorCode = ERROR_INVALID_FUNCTION; |
240 | } | 240 | } |
241 | else | 241 | else |
242 | errorCode = GetLastError(); | 242 | errorCode = GetLastError(); |
@@ -253,7 +253,7 @@ HRESULT CDirItems::AddSecurityItem(const FString &path, int &secureIndex) | |||
253 | return AddError(path, errorCode); | 253 | return AddError(path, errorCode); |
254 | } | 254 | } |
255 | 255 | ||
256 | #endif // _USE_SECURITY_CODE | 256 | #endif // Z7_USE_SECURITY_CODE |
257 | 257 | ||
258 | 258 | ||
259 | HRESULT CDirItems::EnumerateOneDir(const FString &phyPrefix, CObjectVector<NFind::CFileInfo> &files) | 259 | HRESULT CDirItems::EnumerateOneDir(const FString &phyPrefix, CObjectVector<NFind::CFileInfo> &files) |
@@ -277,7 +277,7 @@ HRESULT CDirItems::EnumerateOneDir(const FString &phyPrefix, CObjectVector<NFind | |||
277 | files.Add(fi); | 277 | files.Add(fi); |
278 | if (Callback && (ttt & kScanProgressStepMask) == kScanProgressStepMask) | 278 | if (Callback && (ttt & kScanProgressStepMask) == kScanProgressStepMask) |
279 | { | 279 | { |
280 | RINOK(ScanProgress(phyPrefix)); | 280 | RINOK(ScanProgress(phyPrefix)) |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
@@ -309,7 +309,7 @@ HRESULT CDirItems::EnumerateOneDir(const FString &phyPrefix, CObjectVector<NFind | |||
309 | { | 309 | { |
310 | const FString path = phyPrefix + de.Name; | 310 | const FString path = phyPrefix + de.Name; |
311 | { | 311 | { |
312 | RINOK(AddError(path)); | 312 | RINOK(AddError(path)) |
313 | continue; | 313 | continue; |
314 | } | 314 | } |
315 | } | 315 | } |
@@ -318,7 +318,7 @@ HRESULT CDirItems::EnumerateOneDir(const FString &phyPrefix, CObjectVector<NFind | |||
318 | 318 | ||
319 | if (Callback && (i & kScanProgressStepMask) == kScanProgressStepMask) | 319 | if (Callback && (i & kScanProgressStepMask) == kScanProgressStepMask) |
320 | { | 320 | { |
321 | RINOK(ScanProgress(phyPrefix)); | 321 | RINOK(ScanProgress(phyPrefix)) |
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
@@ -332,10 +332,10 @@ HRESULT CDirItems::EnumerateOneDir(const FString &phyPrefix, CObjectVector<NFind | |||
332 | 332 | ||
333 | HRESULT CDirItems::EnumerateDir(int phyParent, int logParent, const FString &phyPrefix) | 333 | HRESULT CDirItems::EnumerateDir(int phyParent, int logParent, const FString &phyPrefix) |
334 | { | 334 | { |
335 | RINOK(ScanProgress(phyPrefix)); | 335 | RINOK(ScanProgress(phyPrefix)) |
336 | 336 | ||
337 | CObjectVector<NFind::CFileInfo> files; | 337 | CObjectVector<NFind::CFileInfo> files; |
338 | RINOK(EnumerateOneDir(phyPrefix, files)); | 338 | RINOK(EnumerateOneDir(phyPrefix, files)) |
339 | 339 | ||
340 | FOR_VECTOR (i, files) | 340 | FOR_VECTOR (i, files) |
341 | { | 341 | { |
@@ -361,10 +361,10 @@ HRESULT CDirItems::EnumerateDir(int phyParent, int logParent, const FString &phy | |||
361 | if (CanIncludeItem(fi.IsDir())) | 361 | if (CanIncludeItem(fi.IsDir())) |
362 | { | 362 | { |
363 | int secureIndex = -1; | 363 | int secureIndex = -1; |
364 | #ifdef _USE_SECURITY_CODE | 364 | #ifdef Z7_USE_SECURITY_CODE |
365 | if (ReadSecure) | 365 | if (ReadSecure) |
366 | { | 366 | { |
367 | RINOK(AddSecurityItem(phyPrefix + fi.Name, secureIndex)); | 367 | RINOK(AddSecurityItem(phyPrefix + fi.Name, secureIndex)) |
368 | } | 368 | } |
369 | #endif | 369 | #endif |
370 | AddDirFileInfo(phyParent, logParent, secureIndex, fi); | 370 | AddDirFileInfo(phyParent, logParent, secureIndex, fi); |
@@ -372,14 +372,14 @@ HRESULT CDirItems::EnumerateDir(int phyParent, int logParent, const FString &phy | |||
372 | 372 | ||
373 | if (Callback && (i & kScanProgressStepMask) == kScanProgressStepMask) | 373 | if (Callback && (i & kScanProgressStepMask) == kScanProgressStepMask) |
374 | { | 374 | { |
375 | RINOK(ScanProgress(phyPrefix)); | 375 | RINOK(ScanProgress(phyPrefix)) |
376 | } | 376 | } |
377 | 377 | ||
378 | if (fi.IsDir()) | 378 | if (fi.IsDir()) |
379 | { | 379 | { |
380 | const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR; | 380 | const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR; |
381 | unsigned parent = AddPrefix(phyParent, logParent, fs2us(name2)); | 381 | unsigned parent = AddPrefix(phyParent, logParent, fs2us(name2)); |
382 | RINOK(EnumerateDir((int)parent, (int)parent, phyPrefix + name2)); | 382 | RINOK(EnumerateDir((int)parent, (int)parent, phyPrefix + name2)) |
383 | } | 383 | } |
384 | } | 384 | } |
385 | return S_OK; | 385 | return S_OK; |
@@ -412,6 +412,11 @@ HRESULT CDirItems::EnumerateItems2( | |||
412 | const int phyParent = phyPrefix.IsEmpty() ? -1 : (int)AddPrefix(-1, -1, fs2us(phyPrefix)); | 412 | const int phyParent = phyPrefix.IsEmpty() ? -1 : (int)AddPrefix(-1, -1, fs2us(phyPrefix)); |
413 | const int logParent = logPrefix.IsEmpty() ? -1 : (int)AddPrefix(-1, -1, logPrefix); | 413 | const int logParent = logPrefix.IsEmpty() ? -1 : (int)AddPrefix(-1, -1, logPrefix); |
414 | 414 | ||
415 | #ifdef _WIN32 | ||
416 | const bool phyPrefix_isAltStreamPrefix = | ||
417 | NFile::NName::IsAltStreamPrefixWithColon(fs2us(phyPrefix)); | ||
418 | #endif | ||
419 | |||
415 | FOR_VECTOR (i, filePaths) | 420 | FOR_VECTOR (i, filePaths) |
416 | { | 421 | { |
417 | const FString &filePath = filePaths[i]; | 422 | const FString &filePath = filePaths[i]; |
@@ -419,7 +424,7 @@ HRESULT CDirItems::EnumerateItems2( | |||
419 | const FString phyPath = phyPrefix + filePath; | 424 | const FString phyPath = phyPrefix + filePath; |
420 | if (!FindFile_KeepDots(fi, phyPath FOLLOW_LINK_PARAM)) | 425 | if (!FindFile_KeepDots(fi, phyPath FOLLOW_LINK_PARAM)) |
421 | { | 426 | { |
422 | RINOK(AddError(phyPath)); | 427 | RINOK(AddError(phyPath)) |
423 | continue; | 428 | continue; |
424 | } | 429 | } |
425 | if (requestedPaths) | 430 | if (requestedPaths) |
@@ -437,20 +442,28 @@ HRESULT CDirItems::EnumerateItems2( | |||
437 | if (CanIncludeItem(fi.IsDir())) | 442 | if (CanIncludeItem(fi.IsDir())) |
438 | { | 443 | { |
439 | int secureIndex = -1; | 444 | int secureIndex = -1; |
440 | #ifdef _USE_SECURITY_CODE | 445 | #ifdef Z7_USE_SECURITY_CODE |
441 | if (ReadSecure) | 446 | if (ReadSecure) |
442 | { | 447 | { |
443 | RINOK(AddSecurityItem(phyPath, secureIndex)); | 448 | RINOK(AddSecurityItem(phyPath, secureIndex)) |
444 | } | 449 | } |
445 | #endif | 450 | #endif |
451 | #ifdef _WIN32 | ||
452 | if (phyPrefix_isAltStreamPrefix && fi.IsAltStream) | ||
453 | { | ||
454 | const int pos = fi.Name.Find(FChar(':')); | ||
455 | if (pos >= 0) | ||
456 | fi.Name.DeleteFrontal((unsigned)pos + 1); | ||
457 | } | ||
458 | #endif | ||
446 | AddDirFileInfo(phyParentCur, logParent, secureIndex, fi); | 459 | AddDirFileInfo(phyParentCur, logParent, secureIndex, fi); |
447 | } | 460 | } |
448 | 461 | ||
449 | if (fi.IsDir()) | 462 | if (fi.IsDir()) |
450 | { | 463 | { |
451 | const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR; | 464 | const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR; |
452 | unsigned parent = AddPrefix(phyParentCur, logParent, fs2us(name2)); | 465 | const unsigned parent = AddPrefix(phyParentCur, logParent, fs2us(name2)); |
453 | RINOK(EnumerateDir((int)parent, (int)parent, phyPrefix + phyPrefixCur + name2)); | 466 | RINOK(EnumerateDir((int)parent, (int)parent, phyPrefix + phyPrefixCur + name2)) |
454 | } | 467 | } |
455 | } | 468 | } |
456 | 469 | ||
@@ -625,10 +638,10 @@ static HRESULT EnumerateForItem( | |||
625 | if (dirItems.CanIncludeItem(fi.IsDir())) | 638 | if (dirItems.CanIncludeItem(fi.IsDir())) |
626 | { | 639 | { |
627 | int secureIndex = -1; | 640 | int secureIndex = -1; |
628 | #ifdef _USE_SECURITY_CODE | 641 | #ifdef Z7_USE_SECURITY_CODE |
629 | if (dirItems.ReadSecure) | 642 | if (dirItems.ReadSecure) |
630 | { | 643 | { |
631 | RINOK(dirItems.AddSecurityItem(phyPrefix + fi.Name, secureIndex)); | 644 | RINOK(dirItems.AddSecurityItem(phyPrefix + fi.Name, secureIndex)) |
632 | } | 645 | } |
633 | #endif | 646 | #endif |
634 | #if !defined(UNDER_CE) | 647 | #if !defined(UNDER_CE) |
@@ -654,7 +667,7 @@ static HRESULT EnumerateForItem( | |||
654 | if (dirItemIndex >= 0) | 667 | if (dirItemIndex >= 0) |
655 | { | 668 | { |
656 | CDirItem &dirItem = dirItems.Items[(unsigned)dirItemIndex]; | 669 | CDirItem &dirItem = dirItems.Items[(unsigned)dirItemIndex]; |
657 | RINOK(dirItems.SetLinkInfo(dirItem, fi, phyPrefix)); | 670 | RINOK(dirItems.SetLinkInfo(dirItem, fi, phyPrefix)) |
658 | if (dirItem.ReparseData.Size() != 0) | 671 | if (dirItem.ReparseData.Size() != 0) |
659 | return S_OK; | 672 | return S_OK; |
660 | } | 673 | } |
@@ -666,7 +679,7 @@ static HRESULT EnumerateForItem( | |||
666 | phyPrefix + fi.Name, // with (fi.Name) | 679 | phyPrefix + fi.Name, // with (fi.Name) |
667 | newParts, // with (fi.Name) | 680 | newParts, // with (fi.Name) |
668 | addAllSubStreams, | 681 | addAllSubStreams, |
669 | dirItems)); | 682 | dirItems)) |
670 | } | 683 | } |
671 | #endif | 684 | #endif |
672 | 685 | ||
@@ -787,7 +800,7 @@ static HRESULT EnumerateDirItems( | |||
787 | enterToSubFolders = true; | 800 | enterToSubFolders = true; |
788 | } | 801 | } |
789 | 802 | ||
790 | RINOK(dirItems.ScanProgress(phyPrefix)); | 803 | RINOK(dirItems.ScanProgress(phyPrefix)) |
791 | 804 | ||
792 | // try direct_names case at first | 805 | // try direct_names case at first |
793 | if (addParts.IsEmpty() && !enterToSubFolders) | 806 | if (addParts.IsEmpty() && !enterToSubFolders) |
@@ -818,7 +831,7 @@ static HRESULT EnumerateDirItems( | |||
818 | bool needAltStreams = true; | 831 | bool needAltStreams = true; |
819 | #endif | 832 | #endif |
820 | 833 | ||
821 | #ifdef _USE_SECURITY_CODE | 834 | #ifdef Z7_USE_SECURITY_CODE |
822 | bool needSecurity = true; | 835 | bool needSecurity = true; |
823 | #endif | 836 | #endif |
824 | 837 | ||
@@ -838,7 +851,7 @@ static HRESULT EnumerateDirItems( | |||
838 | 851 | ||
839 | /* | 852 | /* |
840 | // do we need to ignore security info for "\\" folder ? | 853 | // do we need to ignore security info for "\\" folder ? |
841 | #ifdef _USE_SECURITY_CODE | 854 | #ifdef Z7_USE_SECURITY_CODE |
842 | needSecurity = false; | 855 | needSecurity = false; |
843 | #endif | 856 | #endif |
844 | */ | 857 | */ |
@@ -866,7 +879,7 @@ static HRESULT EnumerateDirItems( | |||
866 | #endif | 879 | #endif |
867 | if (!FindFile_KeepDots(fi, fullPath FOLLOW_LINK_PARAM2)) | 880 | if (!FindFile_KeepDots(fi, fullPath FOLLOW_LINK_PARAM2)) |
868 | { | 881 | { |
869 | RINOK(dirItems.AddError(fullPath)); | 882 | RINOK(dirItems.AddError(fullPath)) |
870 | continue; | 883 | continue; |
871 | } | 884 | } |
872 | 885 | ||
@@ -884,7 +897,7 @@ static HRESULT EnumerateDirItems( | |||
884 | if (isDir ? !item.ForDir : !item.ForFile) | 897 | if (isDir ? !item.ForDir : !item.ForFile) |
885 | { | 898 | { |
886 | // RINOK(dirItems.AddError(fullPath, isDir ? MY_ERROR_IS_DIR: MY_ERROR_NOT_DIR)); | 899 | // RINOK(dirItems.AddError(fullPath, isDir ? MY_ERROR_IS_DIR: MY_ERROR_NOT_DIR)); |
887 | RINOK(dirItems.AddError(fullPath, DI_DEFAULT_ERROR)); | 900 | RINOK(dirItems.AddError(fullPath, DI_DEFAULT_ERROR)) |
888 | continue; | 901 | continue; |
889 | } | 902 | } |
890 | { | 903 | { |
@@ -898,10 +911,10 @@ static HRESULT EnumerateDirItems( | |||
898 | if (dirItems.CanIncludeItem(fi.IsDir())) | 911 | if (dirItems.CanIncludeItem(fi.IsDir())) |
899 | { | 912 | { |
900 | int secureIndex = -1; | 913 | int secureIndex = -1; |
901 | #ifdef _USE_SECURITY_CODE | 914 | #ifdef Z7_USE_SECURITY_CODE |
902 | if (needSecurity && dirItems.ReadSecure) | 915 | if (needSecurity && dirItems.ReadSecure) |
903 | { | 916 | { |
904 | RINOK(dirItems.AddSecurityItem(fullPath, secureIndex)); | 917 | RINOK(dirItems.AddSecurityItem(fullPath, secureIndex)) |
905 | } | 918 | } |
906 | #endif | 919 | #endif |
907 | 920 | ||
@@ -912,7 +925,7 @@ static HRESULT EnumerateDirItems( | |||
912 | #if !defined(UNDER_CE) | 925 | #if !defined(UNDER_CE) |
913 | { | 926 | { |
914 | CDirItem &dirItem = dirItems.Items.Back(); | 927 | CDirItem &dirItem = dirItems.Items.Back(); |
915 | RINOK(dirItems.SetLinkInfo(dirItem, fi, phyPrefix)); | 928 | RINOK(dirItems.SetLinkInfo(dirItem, fi, phyPrefix)) |
916 | if (dirItem.ReparseData.Size() != 0) | 929 | if (dirItem.ReparseData.Size() != 0) |
917 | continue; | 930 | continue; |
918 | } | 931 | } |
@@ -926,7 +939,7 @@ static HRESULT EnumerateDirItems( | |||
926 | fullPath, // including (name) | 939 | fullPath, // including (name) |
927 | pathParts, // including (fi.Name) | 940 | pathParts, // including (fi.Name) |
928 | true, /* addAllSubStreams */ | 941 | true, /* addAllSubStreams */ |
929 | dirItems)); | 942 | dirItems)) |
930 | } | 943 | } |
931 | #endif // defined(_WIN32) | 944 | #endif // defined(_WIN32) |
932 | 945 | ||
@@ -975,9 +988,9 @@ static HRESULT EnumerateDirItems( | |||
975 | } | 988 | } |
976 | 989 | ||
977 | RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix, | 990 | RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix, |
978 | newParts, dirItems, true)); | 991 | newParts, dirItems, true)) |
979 | } | 992 | } |
980 | 993 | ||
981 | for (i = 0; i < curNode.SubNodes.Size(); i++) | 994 | for (i = 0; i < curNode.SubNodes.Size(); i++) |
982 | { | 995 | { |
983 | if (i < needEnterVector.Size()) | 996 | if (i < needEnterVector.Size()) |
@@ -987,17 +1000,20 @@ static HRESULT EnumerateDirItems( | |||
987 | FString fullPath = phyPrefix + us2fs(nextNode.Name); | 1000 | FString fullPath = phyPrefix + us2fs(nextNode.Name); |
988 | NFind::CFileInfo fi; | 1001 | NFind::CFileInfo fi; |
989 | 1002 | ||
990 | if (phyPrefix.IsEmpty()) | 1003 | if (nextNode.Name.IsEmpty()) |
991 | { | 1004 | { |
992 | { | 1005 | if (phyPrefix.IsEmpty()) |
993 | if (nextNode.Name.IsEmpty()) | 1006 | fullPath = CHAR_PATH_SEPARATOR; |
994 | fullPath = CHAR_PATH_SEPARATOR; | 1007 | } |
995 | #ifdef _WIN32 | 1008 | #ifdef _WIN32 |
996 | else if (NWildcard::IsDriveColonName(nextNode.Name)) | 1009 | else if(phyPrefix.IsEmpty() |
997 | fullPath.Add_PathSepar(); | 1010 | || (phyPrefix.Len() == NName::kSuperPathPrefixSize |
998 | #endif | 1011 | && IsSuperPath(phyPrefix))) |
999 | } | 1012 | { |
1013 | if (NWildcard::IsDriveColonName(nextNode.Name)) | ||
1014 | fullPath.Add_PathSepar(); | ||
1000 | } | 1015 | } |
1016 | #endif | ||
1001 | 1017 | ||
1002 | // we don't want to call fi.Find() for root folder or virtual folder | 1018 | // we don't want to call fi.Find() for root folder or virtual folder |
1003 | if ((phyPrefix.IsEmpty() && nextNode.Name.IsEmpty()) | 1019 | if ((phyPrefix.IsEmpty() && nextNode.Name.IsEmpty()) |
@@ -1015,19 +1031,19 @@ static HRESULT EnumerateDirItems( | |||
1015 | { | 1031 | { |
1016 | if (!nextNode.AreThereIncludeItems()) | 1032 | if (!nextNode.AreThereIncludeItems()) |
1017 | continue; | 1033 | continue; |
1018 | RINOK(dirItems.AddError(fullPath)); | 1034 | RINOK(dirItems.AddError(fullPath)) |
1019 | continue; | 1035 | continue; |
1020 | } | 1036 | } |
1021 | 1037 | ||
1022 | if (!fi.IsDir()) | 1038 | if (!fi.IsDir()) |
1023 | { | 1039 | { |
1024 | RINOK(dirItems.AddError(fullPath, DI_DEFAULT_ERROR)); | 1040 | RINOK(dirItems.AddError(fullPath, DI_DEFAULT_ERROR)) |
1025 | continue; | 1041 | continue; |
1026 | } | 1042 | } |
1027 | } | 1043 | } |
1028 | 1044 | ||
1029 | RINOK(EnumerateDirItems_Spec(nextNode, phyParent, logParent, fi.Name, phyPrefix, | 1045 | RINOK(EnumerateDirItems_Spec(nextNode, phyParent, logParent, fi.Name, phyPrefix, |
1030 | UStringVector(), dirItems, false)); | 1046 | UStringVector(), dirItems, false)) |
1031 | } | 1047 | } |
1032 | 1048 | ||
1033 | return S_OK; | 1049 | return S_OK; |
@@ -1073,7 +1089,7 @@ static HRESULT EnumerateDirItems( | |||
1073 | fi.Name = driveName; | 1089 | fi.Name = driveName; |
1074 | 1090 | ||
1075 | RINOK(EnumerateForItem(fi, curNode, phyParent, logParent, phyPrefix, | 1091 | RINOK(EnumerateForItem(fi, curNode, phyParent, logParent, phyPrefix, |
1076 | addParts, dirItems, enterToSubFolders)); | 1092 | addParts, dirItems, enterToSubFolders)) |
1077 | } | 1093 | } |
1078 | return S_OK; | 1094 | return S_OK; |
1079 | } | 1095 | } |
@@ -1088,7 +1104,7 @@ static HRESULT EnumerateDirItems( | |||
1088 | // for (int y = 0; y < 1; y++) | 1104 | // for (int y = 0; y < 1; y++) |
1089 | { | 1105 | { |
1090 | // files.Clear(); | 1106 | // files.Clear(); |
1091 | RINOK(dirItems.EnumerateOneDir(phyPrefix, files)); | 1107 | RINOK(dirItems.EnumerateOneDir(phyPrefix, files)) |
1092 | /* | 1108 | /* |
1093 | FOR_VECTOR (i, files) | 1109 | FOR_VECTOR (i, files) |
1094 | { | 1110 | { |
@@ -1134,10 +1150,10 @@ static HRESULT EnumerateDirItems( | |||
1134 | #endif | 1150 | #endif |
1135 | 1151 | ||
1136 | RINOK(EnumerateForItem(fi, curNode, phyParent, logParent, phyPrefix, | 1152 | RINOK(EnumerateForItem(fi, curNode, phyParent, logParent, phyPrefix, |
1137 | addParts, dirItems, enterToSubFolders)); | 1153 | addParts, dirItems, enterToSubFolders)) |
1138 | if (dirItems.Callback && (i & kScanProgressStepMask) == kScanProgressStepMask) | 1154 | if (dirItems.Callback && (i & kScanProgressStepMask) == kScanProgressStepMask) |
1139 | { | 1155 | { |
1140 | RINOK(dirItems.ScanProgress(phyPrefix)); | 1156 | RINOK(dirItems.ScanProgress(phyPrefix)) |
1141 | } | 1157 | } |
1142 | } | 1158 | } |
1143 | 1159 | ||
@@ -1170,16 +1186,16 @@ HRESULT EnumerateItems( | |||
1170 | RINOK(EnumerateDirItems(pair.Head, phyParent, logParent, us2fs(pair.Prefix), UStringVector(), | 1186 | RINOK(EnumerateDirItems(pair.Head, phyParent, logParent, us2fs(pair.Prefix), UStringVector(), |
1171 | dirItems, | 1187 | dirItems, |
1172 | false // enterToSubFolders | 1188 | false // enterToSubFolders |
1173 | )); | 1189 | )) |
1174 | } | 1190 | } |
1175 | dirItems.ReserveDown(); | 1191 | dirItems.ReserveDown(); |
1176 | 1192 | ||
1177 | #if defined(_WIN32) && !defined(UNDER_CE) | 1193 | #if defined(_WIN32) && !defined(UNDER_CE) |
1178 | RINOK(dirItems.FillFixedReparse()); | 1194 | RINOK(dirItems.FillFixedReparse()) |
1179 | #endif | 1195 | #endif |
1180 | 1196 | ||
1181 | #ifndef _WIN32 | 1197 | #ifndef _WIN32 |
1182 | RINOK(dirItems.FillDeviceSizes()); | 1198 | RINOK(dirItems.FillDeviceSizes()) |
1183 | #endif | 1199 | #endif |
1184 | 1200 | ||
1185 | return S_OK; | 1201 | return S_OK; |
@@ -1237,7 +1253,7 @@ HRESULT CDirItems::FillFixedReparse() | |||
1237 | } | 1253 | } |
1238 | */ | 1254 | */ |
1239 | 1255 | ||
1240 | RINOK(AddError(phyPath)); | 1256 | RINOK(AddError(phyPath)) |
1241 | continue; | 1257 | continue; |
1242 | } | 1258 | } |
1243 | 1259 | ||
@@ -1485,7 +1501,7 @@ HRESULT EnumerateDirItemsAndSort( | |||
1485 | { | 1501 | { |
1486 | HRESULT res = EnumerateItems(censor, censorPathMode, addPathPrefix, dirItems); | 1502 | HRESULT res = EnumerateItems(censor, censorPathMode, addPathPrefix, dirItems); |
1487 | st = dirItems.Stat; | 1503 | st = dirItems.Stat; |
1488 | RINOK(res); | 1504 | RINOK(res) |
1489 | } | 1505 | } |
1490 | 1506 | ||
1491 | FOR_VECTOR (i, dirItems.Items) | 1507 | FOR_VECTOR (i, dirItems.Items) |
diff --git a/CPP/7zip/UI/Common/EnumDirItems.h b/CPP/7zip/UI/Common/EnumDirItems.h index 9b17c60..24f1c8b 100644 --- a/CPP/7zip/UI/Common/EnumDirItems.h +++ b/CPP/7zip/UI/Common/EnumDirItems.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // EnumDirItems.h | 1 | // EnumDirItems.h |
2 | 2 | ||
3 | #ifndef __ENUM_DIR_ITEMS_H | 3 | #ifndef ZIP7_INC_ENUM_DIR_ITEMS_H |
4 | #define __ENUM_DIR_ITEMS_H | 4 | #define ZIP7_INC_ENUM_DIR_ITEMS_H |
5 | 5 | ||
6 | #include "../../../Common/Wildcard.h" | 6 | #include "../../../Common/Wildcard.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/ExitCode.h b/CPP/7zip/UI/Common/ExitCode.h index b6d7d4d..2d7b029 100644 --- a/CPP/7zip/UI/Common/ExitCode.h +++ b/CPP/7zip/UI/Common/ExitCode.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // ExitCode.h | 1 | // ExitCode.h |
2 | 2 | ||
3 | #ifndef __EXIT_CODE_H | 3 | #ifndef ZIP7_INC_EXIT_CODE_H |
4 | #define __EXIT_CODE_H | 4 | #define ZIP7_INC_EXIT_CODE_H |
5 | 5 | ||
6 | namespace NExitCode { | 6 | namespace NExitCode { |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/Extract.cpp b/CPP/7zip/UI/Common/Extract.cpp index 58f5218..34b4871 100644 --- a/CPP/7zip/UI/Common/Extract.cpp +++ b/CPP/7zip/UI/Common/Extract.cpp | |||
@@ -43,6 +43,7 @@ static HRESULT DecompressArchive( | |||
43 | const CExtractOptions &options, | 43 | const CExtractOptions &options, |
44 | bool calcCrc, | 44 | bool calcCrc, |
45 | IExtractCallbackUI *callback, | 45 | IExtractCallbackUI *callback, |
46 | IFolderArchiveExtractCallback *callbackFAE, | ||
46 | CArchiveExtractCallback *ecs, | 47 | CArchiveExtractCallback *ecs, |
47 | UString &errorMessage, | 48 | UString &errorMessage, |
48 | UInt64 &stdInProcessed) | 49 | UInt64 &stdInProcessed) |
@@ -94,7 +95,7 @@ static HRESULT DecompressArchive( | |||
94 | if (!options.StdInMode) | 95 | if (!options.StdInMode) |
95 | { | 96 | { |
96 | UInt32 numItems; | 97 | UInt32 numItems; |
97 | RINOK(archive->GetNumberOfItems(&numItems)); | 98 | RINOK(archive->GetNumberOfItems(&numItems)) |
98 | 99 | ||
99 | CReadArcItem item; | 100 | CReadArcItem item; |
100 | 101 | ||
@@ -105,7 +106,7 @@ static HRESULT DecompressArchive( | |||
105 | || options.ExcludeDirItems | 106 | || options.ExcludeDirItems |
106 | || options.ExcludeFileItems) | 107 | || options.ExcludeFileItems) |
107 | { | 108 | { |
108 | RINOK(arc.GetItem(i, item)); | 109 | RINOK(arc.GetItem(i, item)) |
109 | if (item.IsDir ? options.ExcludeDirItems : options.ExcludeFileItems) | 110 | if (item.IsDir ? options.ExcludeDirItems : options.ExcludeFileItems) |
110 | continue; | 111 | continue; |
111 | } | 112 | } |
@@ -115,7 +116,7 @@ static HRESULT DecompressArchive( | |||
115 | item.IsAltStream = false; | 116 | item.IsAltStream = false; |
116 | if (!options.NtOptions.AltStreams.Val && arc.Ask_AltStream) | 117 | if (!options.NtOptions.AltStreams.Val && arc.Ask_AltStream) |
117 | { | 118 | { |
118 | RINOK(Archive_IsItem_AltStream(arc.Archive, i, item.IsAltStream)); | 119 | RINOK(Archive_IsItem_AltStream(arc.Archive, i, item.IsAltStream)) |
119 | } | 120 | } |
120 | #endif | 121 | #endif |
121 | } | 122 | } |
@@ -194,7 +195,7 @@ static HRESULT DecompressArchive( | |||
194 | options.NtOptions, | 195 | options.NtOptions, |
195 | options.StdInMode ? &wildcardCensor : NULL, | 196 | options.StdInMode ? &wildcardCensor : NULL, |
196 | &arc, | 197 | &arc, |
197 | callback, | 198 | callbackFAE, |
198 | options.StdOutMode, options.TestMode, | 199 | options.StdOutMode, options.TestMode, |
199 | outDir, | 200 | outDir, |
200 | removePathParts, false, | 201 | removePathParts, false, |
@@ -207,14 +208,14 @@ static HRESULT DecompressArchive( | |||
207 | !options.TestMode && | 208 | !options.TestMode && |
208 | options.NtOptions.HardLinks.Val) | 209 | options.NtOptions.HardLinks.Val) |
209 | { | 210 | { |
210 | RINOK(ecs->PrepareHardLinks(&realIndices)); | 211 | RINOK(ecs->PrepareHardLinks(&realIndices)) |
211 | } | 212 | } |
212 | 213 | ||
213 | #endif | 214 | #endif |
214 | 215 | ||
215 | 216 | ||
216 | HRESULT result; | 217 | HRESULT result; |
217 | Int32 testMode = (options.TestMode && !calcCrc) ? 1: 0; | 218 | const Int32 testMode = (options.TestMode && !calcCrc) ? 1: 0; |
218 | 219 | ||
219 | CArchiveExtractCallback_Closer ecsCloser(ecs); | 220 | CArchiveExtractCallback_Closer ecsCloser(ecs); |
220 | 221 | ||
@@ -228,7 +229,7 @@ static HRESULT DecompressArchive( | |||
228 | else | 229 | else |
229 | result = archive->Extract(&realIndices.Front(), realIndices.Size(), testMode, ecs); | 230 | result = archive->Extract(&realIndices.Front(), realIndices.Size(), testMode, ecs); |
230 | 231 | ||
231 | HRESULT res2 = ecsCloser.Close(); | 232 | const HRESULT res2 = ecsCloser.Close(); |
232 | if (result == S_OK) | 233 | if (result == S_OK) |
233 | result = res2; | 234 | result = res2; |
234 | 235 | ||
@@ -270,7 +271,8 @@ HRESULT Extract( | |||
270 | const CExtractOptions &options, | 271 | const CExtractOptions &options, |
271 | IOpenCallbackUI *openCallback, | 272 | IOpenCallbackUI *openCallback, |
272 | IExtractCallbackUI *extractCallback, | 273 | IExtractCallbackUI *extractCallback, |
273 | #ifndef _SFX | 274 | IFolderArchiveExtractCallback *faeCallback, |
275 | #ifndef Z7_SFX | ||
274 | IHashCalc *hash, | 276 | IHashCalc *hash, |
275 | #endif | 277 | #endif |
276 | UString &errorMessage, | 278 | UString &errorMessage, |
@@ -323,13 +325,13 @@ HRESULT Extract( | |||
323 | options.ZoneMode, | 325 | options.ZoneMode, |
324 | false // keepEmptyDirParts | 326 | false // keepEmptyDirParts |
325 | ); | 327 | ); |
326 | #ifndef _SFX | 328 | #ifndef Z7_SFX |
327 | ecs->SetHashMethods(hash); | 329 | ecs->SetHashMethods(hash); |
328 | #endif | 330 | #endif |
329 | 331 | ||
330 | if (multi) | 332 | if (multi) |
331 | { | 333 | { |
332 | RINOK(extractCallback->SetTotal(totalPackSize)); | 334 | RINOK(faeCallback->SetTotal(totalPackSize)) |
333 | } | 335 | } |
334 | 336 | ||
335 | UInt64 totalPackProcessed = 0; | 337 | UInt64 totalPackProcessed = 0; |
@@ -364,17 +366,17 @@ HRESULT Extract( | |||
364 | } | 366 | } |
365 | 367 | ||
366 | /* | 368 | /* |
367 | #ifndef _NO_CRYPTO | 369 | #ifndef Z7_NO_CRYPTO |
368 | openCallback->Open_Clear_PasswordWasAsked_Flag(); | 370 | openCallback->Open_Clear_PasswordWasAsked_Flag(); |
369 | #endif | 371 | #endif |
370 | */ | 372 | */ |
371 | 373 | ||
372 | RINOK(extractCallback->BeforeOpen(arcPath, options.TestMode)); | 374 | RINOK(extractCallback->BeforeOpen(arcPath, options.TestMode)) |
373 | CArchiveLink arcLink; | 375 | CArchiveLink arcLink; |
374 | 376 | ||
375 | CObjectVector<COpenType> types2 = types; | 377 | CObjectVector<COpenType> types2 = types; |
376 | /* | 378 | /* |
377 | #ifndef _SFX | 379 | #ifndef Z7_SFX |
378 | if (types.IsEmpty()) | 380 | if (types.IsEmpty()) |
379 | { | 381 | { |
380 | int pos = arcPath.ReverseFind(L'.'); | 382 | int pos = arcPath.ReverseFind(L'.'); |
@@ -402,7 +404,7 @@ HRESULT Extract( | |||
402 | */ | 404 | */ |
403 | 405 | ||
404 | COpenOptions op; | 406 | COpenOptions op; |
405 | #ifndef _SFX | 407 | #ifndef Z7_SFX |
406 | op.props = &options.Properties; | 408 | op.props = &options.Properties; |
407 | #endif | 409 | #endif |
408 | op.codecs = codecs; | 410 | op.codecs = codecs; |
@@ -418,7 +420,7 @@ HRESULT Extract( | |||
418 | return result; | 420 | return result; |
419 | 421 | ||
420 | // arcLink.Set_ErrorsText(); | 422 | // arcLink.Set_ErrorsText(); |
421 | RINOK(extractCallback->OpenResult(codecs, arcLink, arcPath, result)); | 423 | RINOK(extractCallback->OpenResult(codecs, arcLink, arcPath, result)) |
422 | 424 | ||
423 | if (result != S_OK) | 425 | if (result != S_OK) |
424 | { | 426 | { |
@@ -428,7 +430,7 @@ HRESULT Extract( | |||
428 | continue; | 430 | continue; |
429 | } | 431 | } |
430 | 432 | ||
431 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(_SFX) | 433 | #if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX) |
432 | if (options.ZoneMode != NExtract::NZoneIdMode::kNone | 434 | if (options.ZoneMode != NExtract::NZoneIdMode::kNone |
433 | && !options.StdInMode) | 435 | && !options.StdInMode) |
434 | { | 436 | { |
@@ -446,7 +448,13 @@ HRESULT Extract( | |||
446 | /* real Extracting to files is possible. | 448 | /* real Extracting to files is possible. |
447 | But user can think that hash archive contains real files. | 449 | But user can think that hash archive contains real files. |
448 | So we block extracting here. */ | 450 | So we block extracting here. */ |
449 | return E_NOTIMPL; | 451 | // v23.00 : we don't break process. |
452 | RINOK(extractCallback->OpenResult(codecs, arcLink, arcPath, E_NOTIMPL)) | ||
453 | thereAreNotOpenArcs = true; | ||
454 | if (!options.StdInMode) | ||
455 | totalPackProcessed += fi.Size; | ||
456 | continue; | ||
457 | // return E_NOTIMPL; // before v23 | ||
450 | } | 458 | } |
451 | FString dirPrefix = us2fs(options.HashDir); | 459 | FString dirPrefix = us2fs(options.HashDir); |
452 | if (dirPrefix.IsEmpty()) | 460 | if (dirPrefix.IsEmpty()) |
@@ -490,7 +498,7 @@ HRESULT Extract( | |||
490 | if (newPackSize < 0) | 498 | if (newPackSize < 0) |
491 | newPackSize = 0; | 499 | newPackSize = 0; |
492 | totalPackSize = (UInt64)newPackSize; | 500 | totalPackSize = (UInt64)newPackSize; |
493 | RINOK(extractCallback->SetTotal(totalPackSize)); | 501 | RINOK(faeCallback->SetTotal(totalPackSize)) |
494 | } | 502 | } |
495 | } | 503 | } |
496 | } | 504 | } |
@@ -498,13 +506,13 @@ HRESULT Extract( | |||
498 | /* | 506 | /* |
499 | // Now openCallback and extractCallback use same object. So we don't need to send password. | 507 | // Now openCallback and extractCallback use same object. So we don't need to send password. |
500 | 508 | ||
501 | #ifndef _NO_CRYPTO | 509 | #ifndef Z7_NO_CRYPTO |
502 | bool passwordIsDefined; | 510 | bool passwordIsDefined; |
503 | UString password; | 511 | UString password; |
504 | RINOK(openCallback->Open_GetPasswordIfAny(passwordIsDefined, password)); | 512 | RINOK(openCallback->Open_GetPasswordIfAny(passwordIsDefined, password)) |
505 | if (passwordIsDefined) | 513 | if (passwordIsDefined) |
506 | { | 514 | { |
507 | RINOK(extractCallback->SetPassword(password)); | 515 | RINOK(extractCallback->SetPassword(password)) |
508 | } | 516 | } |
509 | #endif | 517 | #endif |
510 | */ | 518 | */ |
@@ -520,7 +528,7 @@ HRESULT Extract( | |||
520 | 528 | ||
521 | UInt64 packProcessed; | 529 | UInt64 packProcessed; |
522 | const bool calcCrc = | 530 | const bool calcCrc = |
523 | #ifndef _SFX | 531 | #ifndef Z7_SFX |
524 | (hash != NULL); | 532 | (hash != NULL); |
525 | #else | 533 | #else |
526 | false; | 534 | false; |
@@ -533,7 +541,8 @@ HRESULT Extract( | |||
533 | wildcardCensor, | 541 | wildcardCensor, |
534 | options, | 542 | options, |
535 | calcCrc, | 543 | calcCrc, |
536 | extractCallback, ecs, errorMessage, packProcessed)); | 544 | extractCallback, faeCallback, ecs, |
545 | errorMessage, packProcessed)) | ||
537 | 546 | ||
538 | if (!options.StdInMode) | 547 | if (!options.StdInMode) |
539 | packProcessed = fi.Size + arcLink.VolumesSize; | 548 | packProcessed = fi.Size + arcLink.VolumesSize; |
@@ -546,8 +555,8 @@ HRESULT Extract( | |||
546 | 555 | ||
547 | if (multi || thereAreNotOpenArcs) | 556 | if (multi || thereAreNotOpenArcs) |
548 | { | 557 | { |
549 | RINOK(extractCallback->SetTotal(totalPackSize)); | 558 | RINOK(faeCallback->SetTotal(totalPackSize)) |
550 | RINOK(extractCallback->SetCompleted(&totalPackProcessed)); | 559 | RINOK(faeCallback->SetCompleted(&totalPackProcessed)) |
551 | } | 560 | } |
552 | 561 | ||
553 | st.NumFolders = ecs->NumFolders; | 562 | st.NumFolders = ecs->NumFolders; |
diff --git a/CPP/7zip/UI/Common/Extract.h b/CPP/7zip/UI/Common/Extract.h index f3d1126..b20f607 100644 --- a/CPP/7zip/UI/Common/Extract.h +++ b/CPP/7zip/UI/Common/Extract.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // Extract.h | 1 | // Extract.h |
2 | 2 | ||
3 | #ifndef __EXTRACT_H | 3 | #ifndef ZIP7_INC_EXTRACT_H |
4 | #define __EXTRACT_H | 4 | #define ZIP7_INC_EXTRACT_H |
5 | 5 | ||
6 | #include "../../../Windows/FileFind.h" | 6 | #include "../../../Windows/FileFind.h" |
7 | 7 | ||
@@ -52,12 +52,12 @@ struct CExtractOptions: public CExtractOptionsBase | |||
52 | // bool ShowDialog; | 52 | // bool ShowDialog; |
53 | // bool PasswordEnabled; | 53 | // bool PasswordEnabled; |
54 | // UString Password; | 54 | // UString Password; |
55 | #ifndef _SFX | 55 | #ifndef Z7_SFX |
56 | CObjectVector<CProperty> Properties; | 56 | CObjectVector<CProperty> Properties; |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | /* | 59 | /* |
60 | #ifdef EXTERNAL_CODECS | 60 | #ifdef Z7_EXTERNAL_CODECS |
61 | CCodecs *Codecs; | 61 | CCodecs *Codecs; |
62 | #endif | 62 | #endif |
63 | */ | 63 | */ |
@@ -96,7 +96,8 @@ HRESULT Extract( | |||
96 | const CExtractOptions &options, | 96 | const CExtractOptions &options, |
97 | IOpenCallbackUI *openCallback, | 97 | IOpenCallbackUI *openCallback, |
98 | IExtractCallbackUI *extractCallback, | 98 | IExtractCallbackUI *extractCallback, |
99 | #ifndef _SFX | 99 | IFolderArchiveExtractCallback *faeCallback, |
100 | #ifndef Z7_SFX | ||
100 | IHashCalc *hash, | 101 | IHashCalc *hash, |
101 | #endif | 102 | #endif |
102 | UString &errorMessage, | 103 | UString &errorMessage, |
diff --git a/CPP/7zip/UI/Common/ExtractMode.h b/CPP/7zip/UI/Common/ExtractMode.h index 9ad831e..6e38f26 100644 --- a/CPP/7zip/UI/Common/ExtractMode.h +++ b/CPP/7zip/UI/Common/ExtractMode.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // ExtractMode.h | 1 | // ExtractMode.h |
2 | 2 | ||
3 | #ifndef __EXTRACT_MODE_H | 3 | #ifndef ZIP7_INC_EXTRACT_MODE_H |
4 | #define __EXTRACT_MODE_H | 4 | #define ZIP7_INC_EXTRACT_MODE_H |
5 | 5 | ||
6 | namespace NExtract { | 6 | namespace NExtract { |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/ExtractingFilePath.cpp b/CPP/7zip/UI/Common/ExtractingFilePath.cpp index a1282b7..88da4ad 100644 --- a/CPP/7zip/UI/Common/ExtractingFilePath.cpp +++ b/CPP/7zip/UI/Common/ExtractingFilePath.cpp | |||
@@ -124,7 +124,7 @@ static const char * const g_ReservedNames[] = | |||
124 | 124 | ||
125 | static bool IsSupportedName(const UString &name) | 125 | static bool IsSupportedName(const UString &name) |
126 | { | 126 | { |
127 | for (unsigned i = 0; i < ARRAY_SIZE(g_ReservedNames); i++) | 127 | for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_ReservedNames); i++) |
128 | { | 128 | { |
129 | const char *reservedName = g_ReservedNames[i]; | 129 | const char *reservedName = g_ReservedNames[i]; |
130 | unsigned len = MyStringLen(reservedName); | 130 | unsigned len = MyStringLen(reservedName); |
diff --git a/CPP/7zip/UI/Common/ExtractingFilePath.h b/CPP/7zip/UI/Common/ExtractingFilePath.h index 8f8f9f1..bb1732f 100644 --- a/CPP/7zip/UI/Common/ExtractingFilePath.h +++ b/CPP/7zip/UI/Common/ExtractingFilePath.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // ExtractingFilePath.h | 1 | // ExtractingFilePath.h |
2 | 2 | ||
3 | #ifndef __EXTRACTING_FILE_PATH_H | 3 | #ifndef ZIP7_INC_EXTRACTING_FILE_PATH_H |
4 | #define __EXTRACTING_FILE_PATH_H | 4 | #define ZIP7_INC_EXTRACTING_FILE_PATH_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/HashCalc.cpp b/CPP/7zip/UI/Common/HashCalc.cpp index f0aa4bd..94c8a06 100644 --- a/CPP/7zip/UI/Common/HashCalc.cpp +++ b/CPP/7zip/UI/Common/HashCalc.cpp | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | using namespace NWindows; | 23 | using namespace NWindows; |
24 | 24 | ||
25 | #ifdef EXTERNAL_CODECS | 25 | #ifdef Z7_EXTERNAL_CODECS |
26 | extern const CExternalCodecs *g_ExternalCodecs_Ptr; | 26 | extern const CExternalCodecs *g_ExternalCodecs_Ptr; |
27 | #endif | 27 | #endif |
28 | 28 | ||
@@ -57,7 +57,7 @@ HRESULT CHashBundle::SetMethods(DECL_EXTERNAL_CODECS_LOC_VARS const UStringVecto | |||
57 | for (i = 0; i < names.Size(); i++) | 57 | for (i = 0; i < names.Size(); i++) |
58 | { | 58 | { |
59 | COneMethodInfo m; | 59 | COneMethodInfo m; |
60 | RINOK(m.ParseMethodFromString(names[i])); | 60 | RINOK(m.ParseMethodFromString(names[i])) |
61 | 61 | ||
62 | if (m.MethodName.IsEmpty()) | 62 | if (m.MethodName.IsEmpty()) |
63 | m.MethodName = k_DefaultHashMethod; | 63 | m.MethodName = k_DefaultHashMethod; |
@@ -92,7 +92,7 @@ HRESULT CHashBundle::SetMethods(DECL_EXTERNAL_CODECS_LOC_VARS const UStringVecto | |||
92 | { | 92 | { |
93 | CMyComPtr<IHasher> hasher; | 93 | CMyComPtr<IHasher> hasher; |
94 | AString name; | 94 | AString name; |
95 | RINOK(CreateHasher(EXTERNAL_CODECS_LOC_VARS ids[i], name, hasher)); | 95 | RINOK(CreateHasher(EXTERNAL_CODECS_LOC_VARS ids[i], name, hasher)) |
96 | if (!hasher) | 96 | if (!hasher) |
97 | throw "Can't create hasher"; | 97 | throw "Can't create hasher"; |
98 | const COneMethodInfo &m = methods[i]; | 98 | const COneMethodInfo &m = methods[i]; |
@@ -100,7 +100,7 @@ HRESULT CHashBundle::SetMethods(DECL_EXTERNAL_CODECS_LOC_VARS const UStringVecto | |||
100 | CMyComPtr<ICompressSetCoderProperties> scp; | 100 | CMyComPtr<ICompressSetCoderProperties> scp; |
101 | hasher.QueryInterface(IID_ICompressSetCoderProperties, &scp); | 101 | hasher.QueryInterface(IID_ICompressSetCoderProperties, &scp); |
102 | if (scp) | 102 | if (scp) |
103 | RINOK(m.SetCoderProps(scp, NULL)); | 103 | RINOK(m.SetCoderProps(scp, NULL)) |
104 | } | 104 | } |
105 | const UInt32 digestSize = hasher->GetDigestSize(); | 105 | const UInt32 digestSize = hasher->GetDigestSize(); |
106 | if (digestSize > k_HashCalc_DigestSize_Max) | 106 | if (digestSize > k_HashCalc_DigestSize_Max) |
@@ -330,14 +330,14 @@ static void AddHashResultLine( | |||
330 | if (numSpaces > 0) | 330 | if (numSpaces > 0) |
331 | SetSpacesAndNul(s + pos, (unsigned)numSpaces); | 331 | SetSpacesAndNul(s + pos, (unsigned)numSpaces); |
332 | if (i != 0) | 332 | if (i != 0) |
333 | _s += ' '; | 333 | _s.Add_Space(); |
334 | _s += s; | 334 | _s += s; |
335 | } | 335 | } |
336 | 336 | ||
337 | /* | 337 | /* |
338 | if (showSize) | 338 | if (showSize) |
339 | { | 339 | { |
340 | _s += ' '; | 340 | _s.Add_Space(); |
341 | static const unsigned kSizeField_Len = 13; // same as in HashCon.cpp | 341 | static const unsigned kSizeField_Len = 13; // same as in HashCon.cpp |
342 | char s[kSizeField_Len + 32]; | 342 | char s[kSizeField_Len + 32]; |
343 | char *p = s; | 343 | char *p = s; |
@@ -467,7 +467,7 @@ HRESULT HashCalc( | |||
467 | } | 467 | } |
468 | else | 468 | else |
469 | { | 469 | { |
470 | RINOK(callback->StartScanning()); | 470 | RINOK(callback->StartScanning()) |
471 | 471 | ||
472 | dirItems.SymLinks = options.SymLinks.Val; | 472 | dirItems.SymLinks = options.SymLinks.Val; |
473 | dirItems.ScanAltStreams = options.AltStreamsMode; | 473 | dirItems.ScanAltStreams = options.AltStreamsMode; |
@@ -487,12 +487,12 @@ HRESULT HashCalc( | |||
487 | errorInfo = "Scanning error"; | 487 | errorInfo = "Scanning error"; |
488 | return res; | 488 | return res; |
489 | } | 489 | } |
490 | RINOK(callback->FinishScanning(dirItems.Stat)); | 490 | RINOK(callback->FinishScanning(dirItems.Stat)) |
491 | } | 491 | } |
492 | 492 | ||
493 | unsigned i; | 493 | unsigned i; |
494 | CHashBundle hb; | 494 | CHashBundle hb; |
495 | RINOK(hb.SetMethods(EXTERNAL_CODECS_LOC_VARS options.Methods)); | 495 | RINOK(hb.SetMethods(EXTERNAL_CODECS_LOC_VARS options.Methods)) |
496 | // hb.Init(); | 496 | // hb.Init(); |
497 | 497 | ||
498 | hb.NumErrors = dirItems.Stat.NumErrors; | 498 | hb.NumErrors = dirItems.Stat.NumErrors; |
@@ -500,12 +500,12 @@ HRESULT HashCalc( | |||
500 | UInt64 totalSize = 0; | 500 | UInt64 totalSize = 0; |
501 | if (options.StdInMode) | 501 | if (options.StdInMode) |
502 | { | 502 | { |
503 | RINOK(callback->SetNumFiles(1)); | 503 | RINOK(callback->SetNumFiles(1)) |
504 | } | 504 | } |
505 | else | 505 | else |
506 | { | 506 | { |
507 | totalSize = dirItems.Stat.GetTotalBytes(); | 507 | totalSize = dirItems.Stat.GetTotalBytes(); |
508 | RINOK(callback->SetTotal(totalSize)); | 508 | RINOK(callback->SetTotal(totalSize)) |
509 | } | 509 | } |
510 | 510 | ||
511 | const UInt32 kBufSize = 1 << 15; | 511 | const UInt32 kBufSize = 1 << 15; |
@@ -515,7 +515,7 @@ HRESULT HashCalc( | |||
515 | 515 | ||
516 | UInt64 completeValue = 0; | 516 | UInt64 completeValue = 0; |
517 | 517 | ||
518 | RINOK(callback->BeforeFirstFile(hb)); | 518 | RINOK(callback->BeforeFirstFile(hb)) |
519 | 519 | ||
520 | /* | 520 | /* |
521 | CDynLimBuf hashFileString((size_t)1 << 31); | 521 | CDynLimBuf hashFileString((size_t)1 << 31); |
@@ -575,7 +575,7 @@ HRESULT HashCalc( | |||
575 | if (curSize > di.Size) | 575 | if (curSize > di.Size) |
576 | { | 576 | { |
577 | totalSize += curSize - di.Size; | 577 | totalSize += curSize - di.Size; |
578 | RINOK(callback->SetTotal(totalSize)); | 578 | RINOK(callback->SetTotal(totalSize)) |
579 | // printf("\ntotal = %d MiB\n", (unsigned)(totalSize >> 20)); | 579 | // printf("\ntotal = %d MiB\n", (unsigned)(totalSize >> 20)); |
580 | } | 580 | } |
581 | } | 581 | } |
@@ -585,7 +585,7 @@ HRESULT HashCalc( | |||
585 | } | 585 | } |
586 | } | 586 | } |
587 | 587 | ||
588 | RINOK(callback->GetStream(path, isDir)); | 588 | RINOK(callback->GetStream(path, isDir)) |
589 | UInt64 fileSize = 0; | 589 | UInt64 fileSize = 0; |
590 | 590 | ||
591 | hb.InitForNewFile(); | 591 | hb.InitForNewFile(); |
@@ -597,10 +597,10 @@ HRESULT HashCalc( | |||
597 | if ((step & 0xFF) == 0) | 597 | if ((step & 0xFF) == 0) |
598 | { | 598 | { |
599 | // printf("\ncompl = %d\n", (unsigned)(completeValue >> 20)); | 599 | // printf("\ncompl = %d\n", (unsigned)(completeValue >> 20)); |
600 | RINOK(callback->SetCompleted(&completeValue)); | 600 | RINOK(callback->SetCompleted(&completeValue)) |
601 | } | 601 | } |
602 | UInt32 size; | 602 | UInt32 size; |
603 | RINOK(inStream->Read(buf, kBufSize, &size)); | 603 | RINOK(inStream->Read(buf, kBufSize, &size)) |
604 | if (size == 0) | 604 | if (size == 0) |
605 | break; | 605 | break; |
606 | hb.Update(buf, size); | 606 | hb.Update(buf, size); |
@@ -626,8 +626,8 @@ HRESULT HashCalc( | |||
626 | } | 626 | } |
627 | */ | 627 | */ |
628 | 628 | ||
629 | RINOK(callback->SetOperationResult(fileSize, hb, !isDir)); | 629 | RINOK(callback->SetOperationResult(fileSize, hb, !isDir)) |
630 | RINOK(callback->SetCompleted(&completeValue)); | 630 | RINOK(callback->SetCompleted(&completeValue)) |
631 | } | 631 | } |
632 | 632 | ||
633 | /* | 633 | /* |
@@ -776,7 +776,7 @@ bool CHashPair::ParseCksum(const char *s) | |||
776 | Name = end; | 776 | Name = end; |
777 | 777 | ||
778 | Hash.Alloc(4); | 778 | Hash.Alloc(4); |
779 | SetBe32(Hash, crc); | 779 | SetBe32(Hash, crc) |
780 | 780 | ||
781 | Size_from_Arc = size; | 781 | Size_from_Arc = size; |
782 | Size_from_Arc_Defined = true; | 782 | Size_from_Arc_Defined = true; |
@@ -823,7 +823,7 @@ static UString GetMethod_from_FileName(const UString &name) | |||
823 | } | 823 | } |
824 | const char *m = ""; | 824 | const char *m = ""; |
825 | unsigned i; | 825 | unsigned i; |
826 | for (i = 0; i < ARRAY_SIZE(k_CsumMethodNames); i++) | 826 | for (i = 0; i < Z7_ARRAY_SIZE(k_CsumMethodNames); i++) |
827 | { | 827 | { |
828 | m = k_CsumMethodNames[i]; | 828 | m = k_CsumMethodNames[i]; |
829 | if (isExtension) | 829 | if (isExtension) |
@@ -836,7 +836,7 @@ static UString GetMethod_from_FileName(const UString &name) | |||
836 | break; | 836 | break; |
837 | } | 837 | } |
838 | UString res; | 838 | UString res; |
839 | if (i != ARRAY_SIZE(k_CsumMethodNames)) | 839 | if (i != Z7_ARRAY_SIZE(k_CsumMethodNames)) |
840 | res = m; | 840 | res = m; |
841 | return res; | 841 | return res; |
842 | } | 842 | } |
@@ -1033,27 +1033,27 @@ static const Byte kRawProps[] = | |||
1033 | }; | 1033 | }; |
1034 | 1034 | ||
1035 | 1035 | ||
1036 | STDMETHODIMP CHandler::GetParent(UInt32 /* index */ , UInt32 *parent, UInt32 *parentType) | 1036 | Z7_COM7F_IMF(CHandler::GetParent(UInt32 /* index */ , UInt32 *parent, UInt32 *parentType)) |
1037 | { | 1037 | { |
1038 | *parentType = NParentType::kDir; | 1038 | *parentType = NParentType::kDir; |
1039 | *parent = (UInt32)(Int32)-1; | 1039 | *parent = (UInt32)(Int32)-1; |
1040 | return S_OK; | 1040 | return S_OK; |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps) | 1043 | Z7_COM7F_IMF(CHandler::GetNumRawProps(UInt32 *numProps)) |
1044 | { | 1044 | { |
1045 | *numProps = ARRAY_SIZE(kRawProps); | 1045 | *numProps = Z7_ARRAY_SIZE(kRawProps); |
1046 | return S_OK; | 1046 | return S_OK; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | STDMETHODIMP CHandler::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID) | 1049 | Z7_COM7F_IMF(CHandler::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID)) |
1050 | { | 1050 | { |
1051 | *propID = kRawProps[index]; | 1051 | *propID = kRawProps[index]; |
1052 | *name = 0; | 1052 | *name = NULL; |
1053 | return S_OK; | 1053 | return S_OK; |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType) | 1056 | Z7_COM7F_IMF(CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)) |
1057 | { | 1057 | { |
1058 | *data = NULL; | 1058 | *data = NULL; |
1059 | *dataSize = 0; | 1059 | *dataSize = 0; |
@@ -1077,7 +1077,7 @@ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data | |||
1077 | IMP_IInArchive_Props | 1077 | IMP_IInArchive_Props |
1078 | IMP_IInArchive_ArcProps | 1078 | IMP_IInArchive_ArcProps |
1079 | 1079 | ||
1080 | STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) | 1080 | Z7_COM7F_IMF(CHandler::GetNumberOfItems(UInt32 *numItems)) |
1081 | { | 1081 | { |
1082 | *numItems = HashPairs.Size(); | 1082 | *numItems = HashPairs.Size(); |
1083 | return S_OK; | 1083 | return S_OK; |
@@ -1089,7 +1089,7 @@ static void Add_OptSpace_String(UString &dest, const char *src) | |||
1089 | dest += src; | 1089 | dest += src; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) | 1092 | Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)) |
1093 | { | 1093 | { |
1094 | NWindows::NCOM::CPropVariant prop; | 1094 | NWindows::NCOM::CPropVariant prop; |
1095 | switch (propID) | 1095 | switch (propID) |
@@ -1152,7 +1152,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) | |||
1152 | } | 1152 | } |
1153 | 1153 | ||
1154 | 1154 | ||
1155 | STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) | 1155 | Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)) |
1156 | { | 1156 | { |
1157 | // COM_TRY_BEGIN | 1157 | // COM_TRY_BEGIN |
1158 | NWindows::NCOM::CPropVariant prop; | 1158 | NWindows::NCOM::CPropVariant prop; |
@@ -1206,10 +1206,9 @@ static HRESULT ReadStream_to_Buf(IInStream *stream, CByteBuffer &buf, IArchiveOp | |||
1206 | { | 1206 | { |
1207 | buf.Free(); | 1207 | buf.Free(); |
1208 | UInt64 len; | 1208 | UInt64 len; |
1209 | RINOK(stream->Seek(0, STREAM_SEEK_END, &len)); | 1209 | RINOK(InStream_AtBegin_GetSize(stream, len)) |
1210 | if (len == 0 || len >= ((UInt64)1 << 31)) | 1210 | if (len == 0 || len >= ((UInt64)1 << 31)) |
1211 | return S_FALSE; | 1211 | return S_FALSE; |
1212 | RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL)); | ||
1213 | buf.Alloc((size_t)len); | 1212 | buf.Alloc((size_t)len); |
1214 | UInt64 pos = 0; | 1213 | UInt64 pos = 0; |
1215 | // return ReadStream_FALSE(stream, buf, (size_t)len); | 1214 | // return ReadStream_FALSE(stream, buf, (size_t)len); |
@@ -1218,7 +1217,7 @@ static HRESULT ReadStream_to_Buf(IInStream *stream, CByteBuffer &buf, IArchiveOp | |||
1218 | const UInt32 kBlockSize = ((UInt32)1 << 24); | 1217 | const UInt32 kBlockSize = ((UInt32)1 << 24); |
1219 | const UInt32 curSize = (len < kBlockSize) ? (UInt32)len : kBlockSize; | 1218 | const UInt32 curSize = (len < kBlockSize) ? (UInt32)len : kBlockSize; |
1220 | UInt32 processedSizeLoc; | 1219 | UInt32 processedSizeLoc; |
1221 | RINOK(stream->Read((Byte *)buf + pos, curSize, &processedSizeLoc)); | 1220 | RINOK(stream->Read((Byte *)buf + pos, curSize, &processedSizeLoc)) |
1222 | if (processedSizeLoc == 0) | 1221 | if (processedSizeLoc == 0) |
1223 | return E_FAIL; | 1222 | return E_FAIL; |
1224 | len -= processedSizeLoc; | 1223 | len -= processedSizeLoc; |
@@ -1228,13 +1227,13 @@ static HRESULT ReadStream_to_Buf(IInStream *stream, CByteBuffer &buf, IArchiveOp | |||
1228 | if (openCallback) | 1227 | if (openCallback) |
1229 | { | 1228 | { |
1230 | const UInt64 files = 0; | 1229 | const UInt64 files = 0; |
1231 | RINOK(openCallback->SetCompleted(&files, &pos)); | 1230 | RINOK(openCallback->SetCompleted(&files, &pos)) |
1232 | } | 1231 | } |
1233 | } | 1232 | } |
1234 | } | 1233 | } |
1235 | 1234 | ||
1236 | 1235 | ||
1237 | STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *openCallback) | 1236 | Z7_COM7F_IMF(CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *openCallback)) |
1238 | { | 1237 | { |
1239 | COM_TRY_BEGIN | 1238 | COM_TRY_BEGIN |
1240 | { | 1239 | { |
@@ -1261,12 +1260,13 @@ STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallb | |||
1261 | 1260 | ||
1262 | if (openCallback) | 1261 | if (openCallback) |
1263 | { | 1262 | { |
1264 | CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback; | 1263 | Z7_DECL_CMyComPtr_QI_FROM( |
1265 | openCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback); | 1264 | IArchiveOpenVolumeCallback, |
1266 | NCOM::CPropVariant prop; | 1265 | openVolumeCallback, openCallback) |
1267 | if (openVolumeCallback) | 1266 | if (openVolumeCallback) |
1268 | { | 1267 | { |
1269 | RINOK(openVolumeCallback->GetProperty(kpidName, &prop)); | 1268 | NCOM::CPropVariant prop; |
1269 | RINOK(openVolumeCallback->GetProperty(kpidName, &prop)) | ||
1270 | if (prop.vt == VT_BSTR) | 1270 | if (prop.vt == VT_BSTR) |
1271 | _nameExtenstion = GetMethod_from_FileName(prop.bstrVal); | 1271 | _nameExtenstion = GetMethod_from_FileName(prop.bstrVal); |
1272 | } | 1272 | } |
@@ -1376,7 +1376,7 @@ void CHandler::ClearVars() | |||
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | 1378 | ||
1379 | STDMETHODIMP CHandler::Close() | 1379 | Z7_COM7F_IMF(CHandler::Close()) |
1380 | { | 1380 | { |
1381 | ClearVars(); | 1381 | ClearVars(); |
1382 | _nameExtenstion.Empty(); | 1382 | _nameExtenstion.Empty(); |
@@ -1416,8 +1416,8 @@ static void AddDefaultMethod(UStringVector &methods, unsigned size) | |||
1416 | else if (size == 4) m = "crc32"; | 1416 | else if (size == 4) m = "crc32"; |
1417 | else | 1417 | else |
1418 | return; | 1418 | return; |
1419 | #ifdef EXTERNAL_CODECS | 1419 | #ifdef Z7_EXTERNAL_CODECS |
1420 | const CExternalCodecs *__externalCodecs = g_ExternalCodecs_Ptr; | 1420 | const CExternalCodecs *_externalCodecs = g_ExternalCodecs_Ptr; |
1421 | #endif | 1421 | #endif |
1422 | CMethodId id; | 1422 | CMethodId id; |
1423 | if (FindHashMethod(EXTERNAL_CODECS_LOC_VARS | 1423 | if (FindHashMethod(EXTERNAL_CODECS_LOC_VARS |
@@ -1426,8 +1426,8 @@ static void AddDefaultMethod(UStringVector &methods, unsigned size) | |||
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | 1428 | ||
1429 | STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | 1429 | Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems, |
1430 | Int32 testMode, IArchiveExtractCallback *extractCallback) | 1430 | Int32 testMode, IArchiveExtractCallback *extractCallback)) |
1431 | { | 1431 | { |
1432 | COM_TRY_BEGIN | 1432 | COM_TRY_BEGIN |
1433 | 1433 | ||
@@ -1442,8 +1442,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1442 | if (numItems == 0) | 1442 | if (numItems == 0) |
1443 | return S_OK; | 1443 | return S_OK; |
1444 | 1444 | ||
1445 | #ifdef EXTERNAL_CODECS | 1445 | #ifdef Z7_EXTERNAL_CODECS |
1446 | const CExternalCodecs *__externalCodecs = g_ExternalCodecs_Ptr; | 1446 | const CExternalCodecs *_externalCodecs = g_ExternalCodecs_Ptr; |
1447 | #endif | 1447 | #endif |
1448 | 1448 | ||
1449 | CHashBundle hb_Glob; | 1449 | CHashBundle hb_Glob; |
@@ -1471,15 +1471,17 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1471 | 1471 | ||
1472 | RINOK(hb_Glob.SetMethods( | 1472 | RINOK(hb_Glob.SetMethods( |
1473 | EXTERNAL_CODECS_LOC_VARS | 1473 | EXTERNAL_CODECS_LOC_VARS |
1474 | methods)); | 1474 | methods)) |
1475 | 1475 | ||
1476 | CMyComPtr<IArchiveUpdateCallbackFile> updateCallbackFile; | 1476 | Z7_DECL_CMyComPtr_QI_FROM( |
1477 | extractCallback->QueryInterface(IID_IArchiveUpdateCallbackFile, (void **)&updateCallbackFile); | 1477 | IArchiveUpdateCallbackFile, |
1478 | updateCallbackFile, extractCallback) | ||
1478 | if (!updateCallbackFile) | 1479 | if (!updateCallbackFile) |
1479 | return E_NOTIMPL; | 1480 | return E_NOTIMPL; |
1480 | { | 1481 | { |
1481 | CMyComPtr<IArchiveGetDiskProperty> GetDiskProperty; | 1482 | Z7_DECL_CMyComPtr_QI_FROM( |
1482 | extractCallback->QueryInterface(IID_IArchiveGetDiskProperty, (void **)&GetDiskProperty); | 1483 | IArchiveGetDiskProperty, |
1484 | GetDiskProperty, extractCallback) | ||
1483 | if (GetDiskProperty) | 1485 | if (GetDiskProperty) |
1484 | { | 1486 | { |
1485 | UInt64 totalSize = 0; | 1487 | UInt64 totalSize = 0; |
@@ -1492,13 +1494,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1492 | continue; | 1494 | continue; |
1493 | { | 1495 | { |
1494 | NCOM::CPropVariant prop; | 1496 | NCOM::CPropVariant prop; |
1495 | RINOK(GetDiskProperty->GetDiskProperty(index, kpidSize, &prop)); | 1497 | RINOK(GetDiskProperty->GetDiskProperty(index, kpidSize, &prop)) |
1496 | if (prop.vt != VT_UI8) | 1498 | if (prop.vt != VT_UI8) |
1497 | continue; | 1499 | continue; |
1498 | totalSize += prop.uhVal.QuadPart; | 1500 | totalSize += prop.uhVal.QuadPart; |
1499 | } | 1501 | } |
1500 | } | 1502 | } |
1501 | RINOK(extractCallback->SetTotal(totalSize)); | 1503 | RINOK(extractCallback->SetTotal(totalSize)) |
1502 | // RINOK(Hash_SetTotalUnpacked->Hash_SetTotalUnpacked(indices, numItems)); | 1504 | // RINOK(Hash_SetTotalUnpacked->Hash_SetTotalUnpacked(indices, numItems)); |
1503 | } | 1505 | } |
1504 | } | 1506 | } |
@@ -1516,7 +1518,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1516 | UInt32 i; | 1518 | UInt32 i; |
1517 | for (i = 0; i < numItems; i++) | 1519 | for (i = 0; i < numItems; i++) |
1518 | { | 1520 | { |
1519 | RINOK(lps->SetCur()); | 1521 | RINOK(lps->SetCur()) |
1520 | const UInt32 index = allFilesMode ? i : indices[i]; | 1522 | const UInt32 index = allFilesMode ? i : indices[i]; |
1521 | 1523 | ||
1522 | CHashPair &hp = HashPairs[index]; | 1524 | CHashPair &hp = HashPairs[index]; |
@@ -1528,7 +1530,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1528 | const bool isDir = hp.IsDir(); | 1530 | const bool isDir = hp.IsDir(); |
1529 | if (!isDir) | 1531 | if (!isDir) |
1530 | { | 1532 | { |
1531 | RINOK(updateCallbackFile->GetStream2(index, &inStream, NUpdateNotifyOp::kHashRead)); | 1533 | RINOK(updateCallbackFile->GetStream2(index, &inStream, NUpdateNotifyOp::kHashRead)) |
1532 | if (!inStream) | 1534 | if (!inStream) |
1533 | { | 1535 | { |
1534 | continue; // we have shown error in GetStream2() | 1536 | continue; // we have shown error in GetStream2() |
@@ -1541,7 +1543,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1541 | NArchive::NExtract::NAskMode::kExtract; | 1543 | NArchive::NExtract::NAskMode::kExtract; |
1542 | 1544 | ||
1543 | CMyComPtr<ISequentialOutStream> realOutStream; | 1545 | CMyComPtr<ISequentialOutStream> realOutStream; |
1544 | RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); | 1546 | RINOK(extractCallback->GetStream(index, &realOutStream, askMode)) |
1545 | 1547 | ||
1546 | /* PrepareOperation() can expect kExtract to set | 1548 | /* PrepareOperation() can expect kExtract to set |
1547 | Attrib and security of output file */ | 1549 | Attrib and security of output file */ |
@@ -1570,7 +1572,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1570 | methods_loc.Add(UString(hp.Method)); | 1572 | methods_loc.Add(UString(hp.Method)); |
1571 | RINOK(hb_Loc.SetMethods( | 1573 | RINOK(hb_Loc.SetMethods( |
1572 | EXTERNAL_CODECS_LOC_VARS | 1574 | EXTERNAL_CODECS_LOC_VARS |
1573 | methods_loc)); | 1575 | methods_loc)) |
1574 | } | 1576 | } |
1575 | else | 1577 | else |
1576 | res_SetMethods = E_NOTIMPL; | 1578 | res_SetMethods = E_NOTIMPL; |
@@ -1583,7 +1585,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1583 | hb_Use = &hb_Loc; | 1585 | hb_Use = &hb_Loc; |
1584 | RINOK(hb_Loc.SetMethods( | 1586 | RINOK(hb_Loc.SetMethods( |
1585 | EXTERNAL_CODECS_LOC_VARS | 1587 | EXTERNAL_CODECS_LOC_VARS |
1586 | methods_loc)); | 1588 | methods_loc)) |
1587 | } | 1589 | } |
1588 | } | 1590 | } |
1589 | 1591 | ||
@@ -1596,16 +1598,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1596 | { | 1598 | { |
1597 | if ((step & 0xFF) == 0) | 1599 | if ((step & 0xFF) == 0) |
1598 | { | 1600 | { |
1599 | RINOK(lps->SetRatioInfo(NULL, &fileSize)); | 1601 | RINOK(progress->SetRatioInfo(NULL, &fileSize)) |
1600 | } | 1602 | } |
1601 | UInt32 size; | 1603 | UInt32 size; |
1602 | RINOK(inStream->Read(buf, kBufSize, &size)); | 1604 | RINOK(inStream->Read(buf, kBufSize, &size)) |
1603 | if (size == 0) | 1605 | if (size == 0) |
1604 | break; | 1606 | break; |
1605 | hb_Use->Update(buf, size); | 1607 | hb_Use->Update(buf, size); |
1606 | if (realOutStream) | 1608 | if (realOutStream) |
1607 | { | 1609 | { |
1608 | RINOK(WriteStream(realOutStream, buf, size)); | 1610 | RINOK(WriteStream(realOutStream, buf, size)) |
1609 | } | 1611 | } |
1610 | fileSize += size; | 1612 | fileSize += size; |
1611 | } | 1613 | } |
@@ -1638,7 +1640,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
1638 | } | 1640 | } |
1639 | } | 1641 | } |
1640 | 1642 | ||
1641 | RINOK(extractCallback->SetOperationResult(opRes)); | 1643 | RINOK(extractCallback->SetOperationResult(opRes)) |
1642 | } | 1644 | } |
1643 | 1645 | ||
1644 | return lps->SetCur(); | 1646 | return lps->SetCur(); |
@@ -1668,7 +1670,7 @@ static HRESULT GetPropString(IArchiveUpdateCallback *callback, UInt32 index, PRO | |||
1668 | bool convertSlash) | 1670 | bool convertSlash) |
1669 | { | 1671 | { |
1670 | NCOM::CPropVariant prop; | 1672 | NCOM::CPropVariant prop; |
1671 | RINOK(callback->GetProperty(index, propId, &prop)); | 1673 | RINOK(callback->GetProperty(index, propId, &prop)) |
1672 | if (prop.vt == VT_BSTR) | 1674 | if (prop.vt == VT_BSTR) |
1673 | { | 1675 | { |
1674 | res = prop.bstrVal; | 1676 | res = prop.bstrVal; |
@@ -1681,15 +1683,15 @@ static HRESULT GetPropString(IArchiveUpdateCallback *callback, UInt32 index, PRO | |||
1681 | } | 1683 | } |
1682 | 1684 | ||
1683 | 1685 | ||
1684 | STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type) | 1686 | Z7_COM7F_IMF(CHandler::GetFileTimeType(UInt32 *type)) |
1685 | { | 1687 | { |
1686 | *type = NFileTimeType::kUnix; | 1688 | *type = NFileTimeType::kUnix; |
1687 | return S_OK; | 1689 | return S_OK; |
1688 | } | 1690 | } |
1689 | 1691 | ||
1690 | 1692 | ||
1691 | STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems, | 1693 | Z7_COM7F_IMF(CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems, |
1692 | IArchiveUpdateCallback *callback) | 1694 | IArchiveUpdateCallback *callback)) |
1693 | { | 1695 | { |
1694 | COM_TRY_BEGIN | 1696 | COM_TRY_BEGIN |
1695 | 1697 | ||
@@ -1697,8 +1699,8 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1697 | return E_NOTIMPL; | 1699 | return E_NOTIMPL; |
1698 | 1700 | ||
1699 | /* | 1701 | /* |
1700 | CMyComPtr<IArchiveUpdateCallbackArcProp> reportArcProp; | 1702 | Z7_DECL_CMyComPtr_QI_FROM(IArchiveUpdateCallbackArcProp, |
1701 | callback->QueryInterface(IID_IArchiveUpdateCallbackArcProp, (void **)&reportArcProp); | 1703 | reportArcProp, callback) |
1702 | */ | 1704 | */ |
1703 | 1705 | ||
1704 | CObjectVector<CUpdateItem> updateItems; | 1706 | CObjectVector<CUpdateItem> updateItems; |
@@ -1716,7 +1718,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1716 | if (!callback) | 1718 | if (!callback) |
1717 | return E_FAIL; | 1719 | return E_FAIL; |
1718 | 1720 | ||
1719 | RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArc)); | 1721 | RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArc)) |
1720 | 1722 | ||
1721 | ui.NewProps = IntToBool(newProps); | 1723 | ui.NewProps = IntToBool(newProps); |
1722 | ui.NewData = IntToBool(newData); | 1724 | ui.NewData = IntToBool(newData); |
@@ -1726,7 +1728,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1726 | { | 1728 | { |
1727 | { | 1729 | { |
1728 | NCOM::CPropVariant prop; | 1730 | NCOM::CPropVariant prop; |
1729 | RINOK(callback->GetProperty(i, kpidIsDir, &prop)); | 1731 | RINOK(callback->GetProperty(i, kpidIsDir, &prop)) |
1730 | if (prop.vt == VT_EMPTY) | 1732 | if (prop.vt == VT_EMPTY) |
1731 | ui.IsDir = false; | 1733 | ui.IsDir = false; |
1732 | else if (prop.vt != VT_BOOL) | 1734 | else if (prop.vt != VT_BOOL) |
@@ -1736,7 +1738,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1736 | } | 1738 | } |
1737 | 1739 | ||
1738 | RINOK(GetPropString(callback, i, kpidPath, ui.Path, | 1740 | RINOK(GetPropString(callback, i, kpidPath, ui.Path, |
1739 | true)); // convertSlash | 1741 | true)) // convertSlash |
1740 | /* | 1742 | /* |
1741 | if (ui.IsDir && !ui.Name.IsEmpty() && ui.Name.Back() != '/') | 1743 | if (ui.IsDir && !ui.Name.IsEmpty() && ui.Name.Back() != '/') |
1742 | ui.Name += '/'; | 1744 | ui.Name += '/'; |
@@ -1746,7 +1748,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1746 | if (IntToBool(newData)) | 1748 | if (IntToBool(newData)) |
1747 | { | 1749 | { |
1748 | NCOM::CPropVariant prop; | 1750 | NCOM::CPropVariant prop; |
1749 | RINOK(callback->GetProperty(i, kpidSize, &prop)); | 1751 | RINOK(callback->GetProperty(i, kpidSize, &prop)) |
1750 | if (prop.vt == VT_UI8) | 1752 | if (prop.vt == VT_UI8) |
1751 | { | 1753 | { |
1752 | ui.Size = prop.uhVal.QuadPart; | 1754 | ui.Size = prop.uhVal.QuadPart; |
@@ -1763,11 +1765,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1763 | 1765 | ||
1764 | if (complexity != 0) | 1766 | if (complexity != 0) |
1765 | { | 1767 | { |
1766 | RINOK(callback->SetTotal(complexity)); | 1768 | RINOK(callback->SetTotal(complexity)) |
1767 | } | 1769 | } |
1768 | 1770 | ||
1769 | #ifdef EXTERNAL_CODECS | 1771 | #ifdef Z7_EXTERNAL_CODECS |
1770 | const CExternalCodecs *__externalCodecs = g_ExternalCodecs_Ptr; | 1772 | const CExternalCodecs *_externalCodecs = g_ExternalCodecs_Ptr; |
1771 | #endif | 1773 | #endif |
1772 | 1774 | ||
1773 | CHashBundle hb; | 1775 | CHashBundle hb; |
@@ -1785,13 +1787,13 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1785 | } | 1787 | } |
1786 | else | 1788 | else |
1787 | { | 1789 | { |
1788 | CMyComPtr<IArchiveGetRootProps> getRootProps; | 1790 | Z7_DECL_CMyComPtr_QI_FROM( |
1789 | callback->QueryInterface(IID_IArchiveGetRootProps, (void **)&getRootProps); | 1791 | IArchiveGetRootProps, |
1790 | 1792 | getRootProps, callback) | |
1791 | NCOM::CPropVariant prop; | ||
1792 | if (getRootProps) | 1793 | if (getRootProps) |
1793 | { | 1794 | { |
1794 | RINOK(getRootProps->GetRootProp(kpidArcFileName, &prop)); | 1795 | NCOM::CPropVariant prop; |
1796 | RINOK(getRootProps->GetRootProp(kpidArcFileName, &prop)) | ||
1795 | if (prop.vt == VT_BSTR) | 1797 | if (prop.vt == VT_BSTR) |
1796 | { | 1798 | { |
1797 | const UString method = GetMethod_from_FileName(prop.bstrVal); | 1799 | const UString method = GetMethod_from_FileName(prop.bstrVal); |
@@ -1801,7 +1803,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1801 | } | 1803 | } |
1802 | } | 1804 | } |
1803 | 1805 | ||
1804 | RINOK(hb.SetMethods(EXTERNAL_CODECS_LOC_VARS methods)); | 1806 | RINOK(hb.SetMethods(EXTERNAL_CODECS_LOC_VARS methods)) |
1805 | 1807 | ||
1806 | CLocalProgress *lps = new CLocalProgress; | 1808 | CLocalProgress *lps = new CLocalProgress; |
1807 | CMyComPtr<ICompressProgressInfo> progress = lps; | 1809 | CMyComPtr<ICompressProgressInfo> progress = lps; |
@@ -1834,7 +1836,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1834 | for (i = 0; i < updateItems.Size(); i++) | 1836 | for (i = 0; i < updateItems.Size(); i++) |
1835 | { | 1837 | { |
1836 | lps->InSize = complexity; | 1838 | lps->InSize = complexity; |
1837 | RINOK(lps->SetCur()); | 1839 | RINOK(lps->SetCur()) |
1838 | 1840 | ||
1839 | const CUpdateItem &ui = updateItems[i]; | 1841 | const CUpdateItem &ui = updateItems[i]; |
1840 | 1842 | ||
@@ -1858,12 +1860,13 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1858 | needWrite = false; | 1860 | needWrite = false; |
1859 | else | 1861 | else |
1860 | { | 1862 | { |
1861 | RINOK(res); | 1863 | RINOK(res) |
1862 | 1864 | ||
1863 | if (fileInStream) | 1865 | if (fileInStream) |
1864 | { | 1866 | { |
1865 | CMyComPtr<IStreamGetSize> streamGetSize; | 1867 | Z7_DECL_CMyComPtr_QI_FROM( |
1866 | fileInStream->QueryInterface(IID_IStreamGetSize, (void **)&streamGetSize); | 1868 | IStreamGetSize, |
1869 | streamGetSize, fileInStream) | ||
1867 | if (streamGetSize) | 1870 | if (streamGetSize) |
1868 | { | 1871 | { |
1869 | UInt64 size; | 1872 | UInt64 size; |
@@ -1871,8 +1874,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1871 | currentComplexity = size; | 1874 | currentComplexity = size; |
1872 | } | 1875 | } |
1873 | /* | 1876 | /* |
1874 | CMyComPtr<IStreamGetProps> getProps; | 1877 | Z7_DECL_CMyComPtr_QI_FROM( |
1875 | fileInStream->QueryInterface(IID_IStreamGetProps, (void **)&getProps); | 1878 | IStreamGetProps, |
1879 | getProps, fileInStream) | ||
1876 | if (getProps) | 1880 | if (getProps) |
1877 | { | 1881 | { |
1878 | FILETIME mTime; | 1882 | FILETIME mTime; |
@@ -1901,11 +1905,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1901 | { | 1905 | { |
1902 | if ((step & 0xFF) == 0) | 1906 | if ((step & 0xFF) == 0) |
1903 | { | 1907 | { |
1904 | RINOK(lps->SetRatioInfo(&fileSize, NULL)); | 1908 | RINOK(progress->SetRatioInfo(&fileSize, NULL)) |
1905 | // RINOK(callback->SetCompleted(&completeValue)); | 1909 | // RINOK(callback->SetCompleted(&completeValue)); |
1906 | } | 1910 | } |
1907 | UInt32 size; | 1911 | UInt32 size; |
1908 | RINOK(fileInStream->Read(buf, kBufSize, &size)); | 1912 | RINOK(fileInStream->Read(buf, kBufSize, &size)) |
1909 | if (size == 0) | 1913 | if (size == 0) |
1910 | break; | 1914 | break; |
1911 | hb.Update(buf, size); | 1915 | hb.Update(buf, size); |
@@ -1962,7 +1966,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1962 | } | 1966 | } |
1963 | } | 1967 | } |
1964 | */ | 1968 | */ |
1965 | RINOK(callback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK)); | 1969 | RINOK(callback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK)) |
1966 | } | 1970 | } |
1967 | else | 1971 | else |
1968 | { | 1972 | { |
@@ -1987,7 +1991,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt | |||
1987 | return E_OUTOFMEMORY; | 1991 | return E_OUTOFMEMORY; |
1988 | } | 1992 | } |
1989 | 1993 | ||
1990 | RINOK(WriteStream(outStream, hashFileString, hashFileString.Len())); | 1994 | RINOK(WriteStream(outStream, hashFileString, hashFileString.Len())) |
1991 | 1995 | ||
1992 | return S_OK; | 1996 | return S_OK; |
1993 | COM_TRY_END | 1997 | COM_TRY_END |
@@ -2040,7 +2044,7 @@ HRESULT CHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value) | |||
2040 | } | 2044 | } |
2041 | 2045 | ||
2042 | 2046 | ||
2043 | STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps) | 2047 | Z7_COM7F_IMF(CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)) |
2044 | { | 2048 | { |
2045 | COM_TRY_BEGIN | 2049 | COM_TRY_BEGIN |
2046 | 2050 | ||
@@ -2048,7 +2052,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR | |||
2048 | 2052 | ||
2049 | for (UInt32 i = 0; i < numProps; i++) | 2053 | for (UInt32 i = 0; i < numProps; i++) |
2050 | { | 2054 | { |
2051 | RINOK(SetProperty(names[i], values[i])); | 2055 | RINOK(SetProperty(names[i], values[i])) |
2052 | } | 2056 | } |
2053 | return S_OK; | 2057 | return S_OK; |
2054 | COM_TRY_END | 2058 | COM_TRY_END |
diff --git a/CPP/7zip/UI/Common/HashCalc.h b/CPP/7zip/UI/Common/HashCalc.h index c566caa..0b527c1 100644 --- a/CPP/7zip/UI/Common/HashCalc.h +++ b/CPP/7zip/UI/Common/HashCalc.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // HashCalc.h | 1 | // HashCalc.h |
2 | 2 | ||
3 | #ifndef __HASH_CALC_H | 3 | #ifndef ZIP7_INC_HASH_CALC_H |
4 | #define __HASH_CALC_H | 4 | #define ZIP7_INC_HASH_CALC_H |
5 | 5 | ||
6 | #include "../../../Common/UTFConvert.h" | 6 | #include "../../../Common/UTFConvert.h" |
7 | #include "../../../Common/Wildcard.h" | 7 | #include "../../../Common/Wildcard.h" |
@@ -65,8 +65,10 @@ struct CHasherState | |||
65 | }; | 65 | }; |
66 | 66 | ||
67 | 67 | ||
68 | Z7_PURE_INTERFACES_BEGIN | ||
68 | 69 | ||
69 | struct IHashCalc | 70 | |
71 | DECLARE_INTERFACE(IHashCalc) | ||
70 | { | 72 | { |
71 | virtual void InitForNewFile() = 0; | 73 | virtual void InitForNewFile() = 0; |
72 | virtual void Update(const void *data, UInt32 size) = 0; | 74 | virtual void Update(const void *data, UInt32 size) = 0; |
@@ -74,7 +76,9 @@ struct IHashCalc | |||
74 | virtual void Final(bool isDir, bool isAltStream, const UString &path) = 0; | 76 | virtual void Final(bool isDir, bool isAltStream, const UString &path) = 0; |
75 | }; | 77 | }; |
76 | 78 | ||
77 | struct CHashBundle: public IHashCalc | 79 | Z7_PURE_INTERFACES_END |
80 | |||
81 | struct CHashBundle Z7_final: public IHashCalc | ||
78 | { | 82 | { |
79 | CObjectVector<CHasherState> Hashers; | 83 | CObjectVector<CHasherState> Hashers; |
80 | 84 | ||
@@ -98,32 +102,32 @@ struct CHashBundle: public IHashCalc | |||
98 | NumDirs = NumFiles = NumAltStreams = FilesSize = AltStreamsSize = NumErrors = 0; | 102 | NumDirs = NumFiles = NumAltStreams = FilesSize = AltStreamsSize = NumErrors = 0; |
99 | } | 103 | } |
100 | 104 | ||
101 | virtual ~CHashBundle() {}; | 105 | void InitForNewFile() Z7_override; |
102 | 106 | void Update(const void *data, UInt32 size) Z7_override; | |
103 | void InitForNewFile(); | 107 | void SetSize(UInt64 size) Z7_override; |
104 | void Update(const void *data, UInt32 size); | 108 | void Final(bool isDir, bool isAltStream, const UString &path) Z7_override; |
105 | void SetSize(UInt64 size); | ||
106 | void Final(bool isDir, bool isAltStream, const UString &path); | ||
107 | }; | 109 | }; |
108 | 110 | ||
109 | #define INTERFACE_IHashCallbackUI(x) \ | 111 | Z7_PURE_INTERFACES_BEGIN |
110 | INTERFACE_IDirItemsCallback(x) \ | 112 | |
111 | virtual HRESULT StartScanning() x; \ | 113 | // INTERFACE_IDirItemsCallback(x) |
112 | virtual HRESULT FinishScanning(const CDirItemsStat &st) x; \ | 114 | |
113 | virtual HRESULT SetNumFiles(UInt64 numFiles) x; \ | 115 | #define Z7_IFACEN_IHashCallbackUI(x) \ |
114 | virtual HRESULT SetTotal(UInt64 size) x; \ | 116 | virtual HRESULT StartScanning() x \ |
115 | virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \ | 117 | virtual HRESULT FinishScanning(const CDirItemsStat &st) x \ |
116 | virtual HRESULT CheckBreak() x; \ | 118 | virtual HRESULT SetNumFiles(UInt64 numFiles) x \ |
117 | virtual HRESULT BeforeFirstFile(const CHashBundle &hb) x; \ | 119 | virtual HRESULT SetTotal(UInt64 size) x \ |
118 | virtual HRESULT GetStream(const wchar_t *name, bool isFolder) x; \ | 120 | virtual HRESULT SetCompleted(const UInt64 *completeValue) x \ |
119 | virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x; \ | 121 | virtual HRESULT CheckBreak() x \ |
120 | virtual HRESULT SetOperationResult(UInt64 fileSize, const CHashBundle &hb, bool showHash) x; \ | 122 | virtual HRESULT BeforeFirstFile(const CHashBundle &hb) x \ |
121 | virtual HRESULT AfterLastFile(CHashBundle &hb) x; \ | 123 | virtual HRESULT GetStream(const wchar_t *name, bool isFolder) x \ |
122 | 124 | virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x \ | |
123 | struct IHashCallbackUI: public IDirItemsCallback | 125 | virtual HRESULT SetOperationResult(UInt64 fileSize, const CHashBundle &hb, bool showHash) x \ |
124 | { | 126 | virtual HRESULT AfterLastFile(CHashBundle &hb) x \ |
125 | INTERFACE_IHashCallbackUI(=0) | 127 | |
126 | }; | 128 | Z7_IFACE_DECL_PURE_(IHashCallbackUI, IDirItemsCallback) |
129 | |||
130 | Z7_PURE_INTERFACES_END | ||
127 | 131 | ||
128 | 132 | ||
129 | struct CHashOptionsLocal | 133 | struct CHashOptionsLocal |
@@ -200,7 +204,7 @@ struct CHashOptions | |||
200 | OpenShareForWrite(false), | 204 | OpenShareForWrite(false), |
201 | StdInMode(false), | 205 | StdInMode(false), |
202 | AltStreamsMode(false), | 206 | AltStreamsMode(false), |
203 | PathMode(NWildcard::k_RelatPath) {}; | 207 | PathMode(NWildcard::k_RelatPath) {} |
204 | }; | 208 | }; |
205 | 209 | ||
206 | 210 | ||
@@ -213,7 +217,7 @@ HRESULT HashCalc( | |||
213 | 217 | ||
214 | 218 | ||
215 | 219 | ||
216 | #ifndef _SFX | 220 | #ifndef Z7_SFX |
217 | 221 | ||
218 | namespace NHash { | 222 | namespace NHash { |
219 | 223 | ||
@@ -264,14 +268,12 @@ struct CHashPair | |||
264 | }; | 268 | }; |
265 | 269 | ||
266 | 270 | ||
267 | class CHandler: | 271 | Z7_CLASS_IMP_CHandler_IInArchive_3( |
268 | public IInArchive, | 272 | IArchiveGetRawProps, |
269 | public IArchiveGetRawProps, | 273 | /* public IGetArchiveHashHandler, */ |
270 | // public IGetArchiveHashHandler, | 274 | IOutArchive, |
271 | public IOutArchive, | 275 | ISetProperties |
272 | public ISetProperties, | 276 | ) |
273 | public CMyUnknownImp | ||
274 | { | ||
275 | bool _isArc; | 277 | bool _isArc; |
276 | UInt64 _phySize; | 278 | UInt64 _phySize; |
277 | CObjectVector<CHashPair> HashPairs; | 279 | CObjectVector<CHashPair> HashPairs; |
@@ -313,21 +315,7 @@ class CHandler: | |||
313 | HRESULT SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value); | 315 | HRESULT SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value); |
314 | 316 | ||
315 | public: | 317 | public: |
316 | |||
317 | CHandler(); | 318 | CHandler(); |
318 | |||
319 | MY_UNKNOWN_IMP4( | ||
320 | IInArchive, | ||
321 | IArchiveGetRawProps, | ||
322 | IOutArchive, | ||
323 | ISetProperties | ||
324 | /*, IGetArchiveHashHandler */ | ||
325 | ) | ||
326 | INTERFACE_IInArchive(;) | ||
327 | INTERFACE_IOutArchive(;) | ||
328 | INTERFACE_IArchiveGetRawProps(;) | ||
329 | // STDMETHOD(GetArchiveHashHandler)(CHandler **handler); | ||
330 | STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps); | ||
331 | }; | 319 | }; |
332 | 320 | ||
333 | } | 321 | } |
diff --git a/CPP/7zip/UI/Common/IFileExtractCallback.h b/CPP/7zip/UI/Common/IFileExtractCallback.h index e6a85c6..dd5c0d7 100644 --- a/CPP/7zip/UI/Common/IFileExtractCallback.h +++ b/CPP/7zip/UI/Common/IFileExtractCallback.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // IFileExtractCallback.h | 1 | // IFileExtractCallback.h |
2 | 2 | ||
3 | #ifndef __I_FILE_EXTRACT_CALLBACK_H | 3 | #ifndef ZIP7_INC_I_FILE_EXTRACT_CALLBACK_H |
4 | #define __I_FILE_EXTRACT_CALLBACK_H | 4 | #define ZIP7_INC_I_FILE_EXTRACT_CALLBACK_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
@@ -10,6 +10,15 @@ | |||
10 | #include "LoadCodecs.h" | 10 | #include "LoadCodecs.h" |
11 | #include "OpenArchive.h" | 11 | #include "OpenArchive.h" |
12 | 12 | ||
13 | Z7_PURE_INTERFACES_BEGIN | ||
14 | |||
15 | #define Z7_IFACE_CONSTR_FOLDERARC_SUB(i, base, n) \ | ||
16 | Z7_DECL_IFACE_7ZIP_SUB(i, base, 1, n) \ | ||
17 | { Z7_IFACE_COM7_PURE(i) }; | ||
18 | |||
19 | #define Z7_IFACE_CONSTR_FOLDERARC(i, n) \ | ||
20 | Z7_IFACE_CONSTR_FOLDERARC_SUB(i, IUnknown, n) | ||
21 | |||
13 | namespace NOverwriteAnswer | 22 | namespace NOverwriteAnswer |
14 | { | 23 | { |
15 | enum EEnum | 24 | enum EEnum |
@@ -42,27 +51,21 @@ IID_IFolderArchiveExtractCallback is requested by: | |||
42 | IFolderArchiveExtractCallback is used by Common/ArchiveExtractCallback.cpp | 51 | IFolderArchiveExtractCallback is used by Common/ArchiveExtractCallback.cpp |
43 | */ | 52 | */ |
44 | 53 | ||
45 | #define INTERFACE_IFolderArchiveExtractCallback(x) \ | 54 | #define Z7_IFACEM_IFolderArchiveExtractCallback(x) \ |
46 | STDMETHOD(AskOverwrite)( \ | 55 | x(AskOverwrite( \ |
47 | const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize, \ | 56 | const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize, \ |
48 | const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize, \ | 57 | const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize, \ |
49 | Int32 *answer) x; \ | 58 | Int32 *answer)) \ |
50 | STDMETHOD(PrepareOperation)(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position) x; \ | 59 | x(PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position)) \ |
51 | STDMETHOD(MessageError)(const wchar_t *message) x; \ | 60 | x(MessageError(const wchar_t *message)) \ |
52 | STDMETHOD(SetOperationResult)(Int32 opRes, Int32 encrypted) x; \ | 61 | x(SetOperationResult(Int32 opRes, Int32 encrypted)) \ |
53 | 62 | ||
54 | DECL_INTERFACE_SUB(IFolderArchiveExtractCallback, IProgress, 0x01, 0x07) | 63 | Z7_IFACE_CONSTR_FOLDERARC_SUB(IFolderArchiveExtractCallback, IProgress, 0x07) |
55 | { | ||
56 | INTERFACE_IFolderArchiveExtractCallback(PURE) | ||
57 | }; | ||
58 | 64 | ||
59 | #define INTERFACE_IFolderArchiveExtractCallback2(x) \ | 65 | #define Z7_IFACEM_IFolderArchiveExtractCallback2(x) \ |
60 | STDMETHOD(ReportExtractResult)(Int32 opRes, Int32 encrypted, const wchar_t *name) x; \ | 66 | x(ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name)) \ |
61 | 67 | ||
62 | DECL_INTERFACE_SUB(IFolderArchiveExtractCallback2, IUnknown, 0x01, 0x08) | 68 | Z7_IFACE_CONSTR_FOLDERARC(IFolderArchiveExtractCallback2, 0x08) |
63 | { | ||
64 | INTERFACE_IFolderArchiveExtractCallback2(PURE) | ||
65 | }; | ||
66 | 69 | ||
67 | /* ---------- IExtractCallbackUI ---------- | 70 | /* ---------- IExtractCallbackUI ---------- |
68 | is implemented by | 71 | is implemented by |
@@ -70,45 +73,40 @@ is implemented by | |||
70 | FileManager/ExtractCallback.h CExtractCallbackImp | 73 | FileManager/ExtractCallback.h CExtractCallbackImp |
71 | */ | 74 | */ |
72 | 75 | ||
73 | #ifdef _NO_CRYPTO | 76 | #ifdef Z7_NO_CRYPTO |
74 | #define INTERFACE_IExtractCallbackUI_Crypto(x) | 77 | #define Z7_IFACEM_IExtractCallbackUI_Crypto(px) |
75 | #else | 78 | #else |
76 | #define INTERFACE_IExtractCallbackUI_Crypto(x) \ | 79 | #define Z7_IFACEM_IExtractCallbackUI_Crypto(px) \ |
77 | virtual HRESULT SetPassword(const UString &password) x; | 80 | virtual HRESULT SetPassword(const UString &password) px |
78 | #endif | 81 | #endif |
79 | 82 | ||
80 | #define INTERFACE_IExtractCallbackUI(x) \ | 83 | #define Z7_IFACEN_IExtractCallbackUI(px) \ |
81 | virtual HRESULT BeforeOpen(const wchar_t *name, bool testMode) x; \ | 84 | virtual HRESULT BeforeOpen(const wchar_t *name, bool testMode) px \ |
82 | virtual HRESULT OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result) x; \ | 85 | virtual HRESULT OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result) px \ |
83 | virtual HRESULT ThereAreNoFiles() x; \ | 86 | virtual HRESULT ThereAreNoFiles() px \ |
84 | virtual HRESULT ExtractResult(HRESULT result) x; \ | 87 | virtual HRESULT ExtractResult(HRESULT result) px \ |
85 | INTERFACE_IExtractCallbackUI_Crypto(x) | 88 | Z7_IFACEM_IExtractCallbackUI_Crypto(px) |
86 | 89 | ||
87 | struct IExtractCallbackUI: IFolderArchiveExtractCallback | 90 | // IExtractCallbackUI - is non-COM interface |
88 | { | 91 | // IFolderArchiveExtractCallback - is COM interface |
89 | INTERFACE_IExtractCallbackUI(PURE) | 92 | // Z7_IFACE_DECL_PURE_(IExtractCallbackUI, IFolderArchiveExtractCallback) |
90 | }; | 93 | Z7_IFACE_DECL_PURE(IExtractCallbackUI) |
91 | 94 | ||
92 | 95 | ||
93 | 96 | ||
94 | #define INTERFACE_IGetProp(x) \ | 97 | #define Z7_IFACEM_IGetProp(x) \ |
95 | STDMETHOD(GetProp)(PROPID propID, PROPVARIANT *value) x; \ | 98 | x(GetProp(PROPID propID, PROPVARIANT *value)) \ |
96 | 99 | ||
97 | DECL_INTERFACE_SUB(IGetProp, IUnknown, 0x01, 0x20) | 100 | Z7_IFACE_CONSTR_FOLDERARC(IGetProp, 0x20) |
98 | { | ||
99 | INTERFACE_IGetProp(PURE) | ||
100 | }; | ||
101 | 101 | ||
102 | #define INTERFACE_IFolderExtractToStreamCallback(x) \ | 102 | #define Z7_IFACEM_IFolderExtractToStreamCallback(x) \ |
103 | STDMETHOD(UseExtractToStream)(Int32 *res) x; \ | 103 | x(UseExtractToStream(Int32 *res)) \ |
104 | STDMETHOD(GetStream7)(const wchar_t *name, Int32 isDir, ISequentialOutStream **outStream, Int32 askExtractMode, IGetProp *getProp) x; \ | 104 | x(GetStream7(const wchar_t *name, Int32 isDir, ISequentialOutStream **outStream, Int32 askExtractMode, IGetProp *getProp)) \ |
105 | STDMETHOD(PrepareOperation7)(Int32 askExtractMode) x; \ | 105 | x(PrepareOperation7(Int32 askExtractMode)) \ |
106 | STDMETHOD(SetOperationResult8)(Int32 resultEOperationResult, Int32 encrypted, UInt64 size) x; \ | 106 | x(SetOperationResult8(Int32 resultEOperationResult, Int32 encrypted, UInt64 size)) \ |
107 | 107 | ||
108 | DECL_INTERFACE_SUB(IFolderExtractToStreamCallback, IUnknown, 0x01, 0x31) | 108 | Z7_IFACE_CONSTR_FOLDERARC(IFolderExtractToStreamCallback, 0x31) |
109 | { | ||
110 | INTERFACE_IFolderExtractToStreamCallback(PURE) | ||
111 | }; | ||
112 | 109 | ||
110 | Z7_PURE_INTERFACES_END | ||
113 | 111 | ||
114 | #endif | 112 | #endif |
diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp index b6a2073..5a65bdc 100644 --- a/CPP/7zip/UI/Common/LoadCodecs.cpp +++ b/CPP/7zip/UI/Common/LoadCodecs.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | // LoadCodecs.cpp | 1 | // LoadCodecs.cpp |
2 | 2 | ||
3 | /* | 3 | /* |
4 | EXTERNAL_CODECS | 4 | Z7_EXTERNAL_CODECS |
5 | --------------- | 5 | --------------- |
6 | CCodecs::Load() tries to detect the directory with plugins. | 6 | CCodecs::Load() tries to detect the directory with plugins. |
7 | It stops the checking, if it can find any of the following items: | 7 | It stops the checking, if it can find any of the following items: |
@@ -22,7 +22,7 @@ EXTERNAL_CODECS | |||
22 | 22 | ||
23 | EXPORT_CODECS | 23 | EXPORT_CODECS |
24 | ------------- | 24 | ------------- |
25 | if (EXTERNAL_CODECS) is defined, then the code exports internal | 25 | if (Z7_EXTERNAL_CODECS) is defined, then the code exports internal |
26 | codecs of client from CCodecs object to external plugins. | 26 | codecs of client from CCodecs object to external plugins. |
27 | 7-Zip doesn't use that feature. 7-Zip uses the scheme: | 27 | 7-Zip doesn't use that feature. 7-Zip uses the scheme: |
28 | - client application without internal plugins. | 28 | - client application without internal plugins. |
@@ -43,29 +43,15 @@ EXPORT_CODECS | |||
43 | 43 | ||
44 | #include "LoadCodecs.h" | 44 | #include "LoadCodecs.h" |
45 | 45 | ||
46 | using namespace NWindows; | ||
47 | |||
48 | #ifdef NEW_FOLDER_INTERFACE | ||
49 | #include "../../../Common/StringToInt.h" | ||
50 | #endif | ||
51 | |||
52 | #include "../../ICoder.h" | 46 | #include "../../ICoder.h" |
53 | #include "../../Common/RegisterArc.h" | 47 | #include "../../Common/RegisterArc.h" |
54 | #include "../../Common/RegisterCodec.h" | 48 | #include "../../Common/RegisterCodec.h" |
55 | 49 | ||
56 | #ifdef EXTERNAL_CODECS | 50 | #ifdef Z7_EXTERNAL_CODECS |
57 | |||
58 | // #define EXPORT_CODECS | 51 | // #define EXPORT_CODECS |
59 | |||
60 | #endif | ||
61 | |||
62 | #ifdef NEW_FOLDER_INTERFACE | ||
63 | extern HINSTANCE g_hInstance; | ||
64 | #include "../../../Windows/ResourceString.h" | ||
65 | static const UINT kIconTypesResId = 100; | ||
66 | #endif | 52 | #endif |
67 | 53 | ||
68 | #ifdef EXTERNAL_CODECS | 54 | #ifdef Z7_EXTERNAL_CODECS |
69 | 55 | ||
70 | #include "../../../Windows/FileFind.h" | 56 | #include "../../../Windows/FileFind.h" |
71 | #include "../../../Windows/DLL.h" | 57 | #include "../../../Windows/DLL.h" |
@@ -75,6 +61,7 @@ static const UINT kIconTypesResId = 100; | |||
75 | #include "../../../Windows/Registry.h" | 61 | #include "../../../Windows/Registry.h" |
76 | #endif | 62 | #endif |
77 | 63 | ||
64 | using namespace NWindows; | ||
78 | using namespace NFile; | 65 | using namespace NFile; |
79 | 66 | ||
80 | 67 | ||
@@ -119,10 +106,10 @@ static bool ReadPathFromRegistry(HKEY baseKey, LPCWSTR value, FString &path) | |||
119 | 106 | ||
120 | #endif // _WIN32 | 107 | #endif // _WIN32 |
121 | 108 | ||
122 | #endif // EXTERNAL_CODECS | 109 | #endif // Z7_EXTERNAL_CODECS |
123 | 110 | ||
124 | 111 | ||
125 | static const unsigned kNumArcsMax = 64; | 112 | static const unsigned kNumArcsMax = 72; |
126 | static unsigned g_NumArcs = 0; | 113 | static unsigned g_NumArcs = 0; |
127 | static const CArcInfo *g_Arcs[kNumArcsMax]; | 114 | static const CArcInfo *g_Arcs[kNumArcsMax]; |
128 | 115 | ||
@@ -133,8 +120,10 @@ void RegisterArc(const CArcInfo *arcInfo) throw() | |||
133 | g_Arcs[g_NumArcs] = arcInfo; | 120 | g_Arcs[g_NumArcs] = arcInfo; |
134 | g_NumArcs++; | 121 | g_NumArcs++; |
135 | } | 122 | } |
123 | // else throw 1; | ||
136 | } | 124 | } |
137 | 125 | ||
126 | /* | ||
138 | static void SplitString(const UString &srcString, UStringVector &destStrings) | 127 | static void SplitString(const UString &srcString, UStringVector &destStrings) |
139 | { | 128 | { |
140 | destStrings.Clear(); | 129 | destStrings.Clear(); |
@@ -159,6 +148,7 @@ static void SplitString(const UString &srcString, UStringVector &destStrings) | |||
159 | if (!s.IsEmpty()) | 148 | if (!s.IsEmpty()) |
160 | destStrings.Add(s); | 149 | destStrings.Add(s); |
161 | } | 150 | } |
151 | */ | ||
162 | 152 | ||
163 | int CArcInfoEx::FindExtension(const UString &ext) const | 153 | int CArcInfoEx::FindExtension(const UString &ext) const |
164 | { | 154 | { |
@@ -187,7 +177,7 @@ void CArcInfoEx::AddExts(const UString &ext, const UString &addExt) | |||
187 | } | 177 | } |
188 | } | 178 | } |
189 | 179 | ||
190 | #ifndef _SFX | 180 | #ifndef Z7_SFX |
191 | 181 | ||
192 | static bool ParseSignatures(const Byte *data, unsigned size, CObjectVector<CByteBuffer> &signatures) | 182 | static bool ParseSignatures(const Byte *data, unsigned size, CObjectVector<CByteBuffer> &signatures) |
193 | { | 183 | { |
@@ -205,11 +195,11 @@ static bool ParseSignatures(const Byte *data, unsigned size, CObjectVector<CByte | |||
205 | return true; | 195 | return true; |
206 | } | 196 | } |
207 | 197 | ||
208 | #endif // _SFX | 198 | #endif // Z7_SFX |
209 | 199 | ||
210 | // #include <stdio.h> | 200 | // #include <stdio.h> |
211 | 201 | ||
212 | #ifdef EXTERNAL_CODECS | 202 | #ifdef Z7_EXTERNAL_CODECS |
213 | 203 | ||
214 | static FString GetBaseFolderPrefixFromRegistry() | 204 | static FString GetBaseFolderPrefixFromRegistry() |
215 | { | 205 | { |
@@ -238,7 +228,7 @@ static HRESULT GetCoderClass(Func_GetMethodProperty getMethodProperty, UInt32 in | |||
238 | { | 228 | { |
239 | NCOM::CPropVariant prop; | 229 | NCOM::CPropVariant prop; |
240 | isAssigned = false; | 230 | isAssigned = false; |
241 | RINOK(getMethodProperty(index, propId, &prop)); | 231 | RINOK(getMethodProperty(index, propId, &prop)) |
242 | if (prop.vt == VT_BSTR) | 232 | if (prop.vt == VT_BSTR) |
243 | { | 233 | { |
244 | if (::SysStringByteLen(prop.bstrVal) != sizeof(GUID)) | 234 | if (::SysStringByteLen(prop.bstrVal) != sizeof(GUID)) |
@@ -258,7 +248,7 @@ static HRESULT GetMethodBoolProp(Func_GetMethodProperty getMethodProperty, UInt3 | |||
258 | NCOM::CPropVariant prop; | 248 | NCOM::CPropVariant prop; |
259 | resVal = false; | 249 | resVal = false; |
260 | isAssigned = false; | 250 | isAssigned = false; |
261 | RINOK(getMethodProperty(index, propId, &prop)); | 251 | RINOK(getMethodProperty(index, propId, &prop)) |
262 | if (prop.vt == VT_BOOL) | 252 | if (prop.vt == VT_BOOL) |
263 | { | 253 | { |
264 | isAssigned = true; | 254 | isAssigned = true; |
@@ -269,45 +259,49 @@ static HRESULT GetMethodBoolProp(Func_GetMethodProperty getMethodProperty, UInt3 | |||
269 | return S_OK; | 259 | return S_OK; |
270 | } | 260 | } |
271 | 261 | ||
262 | #if defined(__clang__) | ||
263 | #pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" | ||
264 | #endif | ||
272 | 265 | ||
273 | #define MY_GET_FUNC(dest, type, func) *(void **)(&dest) = (func); | 266 | #define MY_GET_FUNC(dest, type, lib, func) \ |
267 | dest = Z7_GET_PROC_ADDRESS(type, lib.Get_HMODULE(), func); | ||
274 | // #define MY_GET_FUNC(dest, type, func) dest = (type)(func); | 268 | // #define MY_GET_FUNC(dest, type, func) dest = (type)(func); |
275 | 269 | ||
276 | #define MY_GET_FUNC_LOC(dest, type, func) \ | 270 | #define MY_GET_FUNC_LOC(dest, type, lib, func) \ |
277 | type dest; MY_GET_FUNC(dest, type, func) | 271 | type dest; MY_GET_FUNC(dest, type, lib, func) |
278 | 272 | ||
279 | HRESULT CCodecs::LoadCodecs() | 273 | HRESULT CCodecs::LoadCodecs() |
280 | { | 274 | { |
281 | CCodecLib &lib = Libs.Back(); | 275 | CCodecLib &lib = Libs.Back(); |
282 | 276 | ||
283 | MY_GET_FUNC (lib.CreateDecoder, Func_CreateDecoder, lib.Lib.GetProc("CreateDecoder")); | 277 | MY_GET_FUNC (lib.CreateDecoder, Func_CreateDecoder, lib.Lib, "CreateDecoder") |
284 | MY_GET_FUNC (lib.CreateEncoder, Func_CreateEncoder, lib.Lib.GetProc("CreateEncoder")); | 278 | MY_GET_FUNC (lib.CreateEncoder, Func_CreateEncoder, lib.Lib, "CreateEncoder") |
285 | MY_GET_FUNC (lib.GetMethodProperty, Func_GetMethodProperty, lib.Lib.GetProc("GetMethodProperty")); | 279 | MY_GET_FUNC (lib.GetMethodProperty, Func_GetMethodProperty, lib.Lib, "GetMethodProperty") |
286 | 280 | ||
287 | if (lib.GetMethodProperty) | 281 | if (lib.GetMethodProperty) |
288 | { | 282 | { |
289 | UInt32 numMethods = 1; | 283 | UInt32 numMethods = 1; |
290 | MY_GET_FUNC_LOC (getNumberOfMethods, Func_GetNumberOfMethods, lib.Lib.GetProc("GetNumberOfMethods")); | 284 | MY_GET_FUNC_LOC (getNumberOfMethods, Func_GetNumberOfMethods, lib.Lib, "GetNumberOfMethods") |
291 | if (getNumberOfMethods) | 285 | if (getNumberOfMethods) |
292 | { | 286 | { |
293 | RINOK(getNumberOfMethods(&numMethods)); | 287 | RINOK(getNumberOfMethods(&numMethods)) |
294 | } | 288 | } |
295 | for (UInt32 i = 0; i < numMethods; i++) | 289 | for (UInt32 i = 0; i < numMethods; i++) |
296 | { | 290 | { |
297 | CDllCodecInfo info; | 291 | CDllCodecInfo info; |
298 | info.LibIndex = Libs.Size() - 1; | 292 | info.LibIndex = Libs.Size() - 1; |
299 | info.CodecIndex = i; | 293 | info.CodecIndex = i; |
300 | RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kEncoder, info.Encoder, info.EncoderIsAssigned)); | 294 | RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kEncoder, info.Encoder, info.EncoderIsAssigned)) |
301 | RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kDecoder, info.Decoder, info.DecoderIsAssigned)); | 295 | RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kDecoder, info.Decoder, info.DecoderIsAssigned)) |
302 | RINOK(GetMethodBoolProp(lib.GetMethodProperty, i, NMethodPropID::kIsFilter, info.IsFilter, info.IsFilter_Assigned)); | 296 | RINOK(GetMethodBoolProp(lib.GetMethodProperty, i, NMethodPropID::kIsFilter, info.IsFilter, info.IsFilter_Assigned)) |
303 | Codecs.Add(info); | 297 | Codecs.Add(info); |
304 | } | 298 | } |
305 | } | 299 | } |
306 | 300 | ||
307 | MY_GET_FUNC_LOC (getHashers, Func_GetHashers, lib.Lib.GetProc("GetHashers")); | 301 | MY_GET_FUNC_LOC (getHashers, Func_GetHashers, lib.Lib, "GetHashers") |
308 | if (getHashers) | 302 | if (getHashers) |
309 | { | 303 | { |
310 | RINOK(getHashers(&lib.ComHashers)); | 304 | RINOK(getHashers(&lib.ComHashers)) |
311 | if (lib.ComHashers) | 305 | if (lib.ComHashers) |
312 | { | 306 | { |
313 | UInt32 numMethods = lib.ComHashers->GetNumHashers(); | 307 | UInt32 numMethods = lib.ComHashers->GetNumHashers(); |
@@ -330,7 +324,7 @@ static HRESULT GetProp( | |||
330 | UInt32 index, PROPID propID, NCOM::CPropVariant &prop) | 324 | UInt32 index, PROPID propID, NCOM::CPropVariant &prop) |
331 | { | 325 | { |
332 | if (getProp2) | 326 | if (getProp2) |
333 | return getProp2(index, propID, &prop);; | 327 | return getProp2(index, propID, &prop); |
334 | return getProp(propID, &prop); | 328 | return getProp(propID, &prop); |
335 | } | 329 | } |
336 | 330 | ||
@@ -341,7 +335,7 @@ static HRESULT GetProp_Bool( | |||
341 | { | 335 | { |
342 | res = false; | 336 | res = false; |
343 | NCOM::CPropVariant prop; | 337 | NCOM::CPropVariant prop; |
344 | RINOK(GetProp(getProp, getProp2, index, propID, prop)); | 338 | RINOK(GetProp(getProp, getProp2, index, propID, prop)) |
345 | if (prop.vt == VT_BOOL) | 339 | if (prop.vt == VT_BOOL) |
346 | res = VARIANT_BOOLToBool(prop.boolVal); | 340 | res = VARIANT_BOOLToBool(prop.boolVal); |
347 | else if (prop.vt != VT_EMPTY) | 341 | else if (prop.vt != VT_EMPTY) |
@@ -357,7 +351,7 @@ static HRESULT GetProp_UInt32( | |||
357 | res = 0; | 351 | res = 0; |
358 | defined = false; | 352 | defined = false; |
359 | NCOM::CPropVariant prop; | 353 | NCOM::CPropVariant prop; |
360 | RINOK(GetProp(getProp, getProp2, index, propID, prop)); | 354 | RINOK(GetProp(getProp, getProp2, index, propID, prop)) |
361 | if (prop.vt == VT_UI4) | 355 | if (prop.vt == VT_UI4) |
362 | { | 356 | { |
363 | res = prop.ulVal; | 357 | res = prop.ulVal; |
@@ -375,7 +369,7 @@ static HRESULT GetProp_String( | |||
375 | { | 369 | { |
376 | res.Empty(); | 370 | res.Empty(); |
377 | NCOM::CPropVariant prop; | 371 | NCOM::CPropVariant prop; |
378 | RINOK(GetProp(getProp, getProp2, index, propID, prop)); | 372 | RINOK(GetProp(getProp, getProp2, index, propID, prop)) |
379 | if (prop.vt == VT_BSTR) | 373 | if (prop.vt == VT_BSTR) |
380 | res.SetFromBstr(prop.bstrVal); | 374 | res.SetFromBstr(prop.bstrVal); |
381 | else if (prop.vt != VT_EMPTY) | 375 | else if (prop.vt != VT_EMPTY) |
@@ -390,7 +384,7 @@ static HRESULT GetProp_RawData( | |||
390 | { | 384 | { |
391 | bb.Free(); | 385 | bb.Free(); |
392 | NCOM::CPropVariant prop; | 386 | NCOM::CPropVariant prop; |
393 | RINOK(GetProp(getProp, getProp2, index, propID, prop)); | 387 | RINOK(GetProp(getProp, getProp2, index, propID, prop)) |
394 | if (prop.vt == VT_BSTR) | 388 | if (prop.vt == VT_BSTR) |
395 | { | 389 | { |
396 | UINT len = ::SysStringByteLen(prop.bstrVal); | 390 | UINT len = ::SysStringByteLen(prop.bstrVal); |
@@ -413,22 +407,22 @@ HRESULT CCodecs::LoadFormats() | |||
413 | const NDLL::CLibrary &lib = Libs.Back().Lib; | 407 | const NDLL::CLibrary &lib = Libs.Back().Lib; |
414 | 408 | ||
415 | Func_GetHandlerProperty getProp = NULL; | 409 | Func_GetHandlerProperty getProp = NULL; |
416 | MY_GET_FUNC_LOC (getProp2, Func_GetHandlerProperty2, lib.GetProc("GetHandlerProperty2")); | 410 | MY_GET_FUNC_LOC (getProp2, Func_GetHandlerProperty2, lib, "GetHandlerProperty2") |
417 | MY_GET_FUNC_LOC (getIsArc, Func_GetIsArc, lib.GetProc("GetIsArc")); | 411 | MY_GET_FUNC_LOC (getIsArc, Func_GetIsArc, lib, "GetIsArc") |
418 | 412 | ||
419 | UInt32 numFormats = 1; | 413 | UInt32 numFormats = 1; |
420 | 414 | ||
421 | if (getProp2) | 415 | if (getProp2) |
422 | { | 416 | { |
423 | MY_GET_FUNC_LOC (getNumberOfFormats, Func_GetNumberOfFormats, lib.GetProc("GetNumberOfFormats")); | 417 | MY_GET_FUNC_LOC (getNumberOfFormats, Func_GetNumberOfFormats, lib, "GetNumberOfFormats") |
424 | if (getNumberOfFormats) | 418 | if (getNumberOfFormats) |
425 | { | 419 | { |
426 | RINOK(getNumberOfFormats(&numFormats)); | 420 | RINOK(getNumberOfFormats(&numFormats)) |
427 | } | 421 | } |
428 | } | 422 | } |
429 | else | 423 | else |
430 | { | 424 | { |
431 | MY_GET_FUNC (getProp, Func_GetHandlerProperty, lib.GetProc("GetHandlerProperty")); | 425 | MY_GET_FUNC (getProp, Func_GetHandlerProperty, lib, "GetHandlerProperty") |
432 | if (!getProp) | 426 | if (!getProp) |
433 | return S_OK; | 427 | return S_OK; |
434 | } | 428 | } |
@@ -439,7 +433,7 @@ HRESULT CCodecs::LoadFormats() | |||
439 | item.LibIndex = (int)(Libs.Size() - 1); | 433 | item.LibIndex = (int)(Libs.Size() - 1); |
440 | item.FormatIndex = i; | 434 | item.FormatIndex = i; |
441 | 435 | ||
442 | RINOK(GetProp_String(getProp, getProp2, i, NArchive::NHandlerPropID::kName, item.Name)); | 436 | RINOK(GetProp_String(getProp, getProp2, i, NArchive::NHandlerPropID::kName, item.Name)) |
443 | 437 | ||
444 | { | 438 | { |
445 | NCOM::CPropVariant prop; | 439 | NCOM::CPropVariant prop; |
@@ -454,18 +448,18 @@ HRESULT CCodecs::LoadFormats() | |||
454 | } | 448 | } |
455 | 449 | ||
456 | UString ext, addExt; | 450 | UString ext, addExt; |
457 | RINOK(GetProp_String(getProp, getProp2, i, NArchive::NHandlerPropID::kExtension, ext)); | 451 | RINOK(GetProp_String(getProp, getProp2, i, NArchive::NHandlerPropID::kExtension, ext)) |
458 | RINOK(GetProp_String(getProp, getProp2, i, NArchive::NHandlerPropID::kAddExtension, addExt)); | 452 | RINOK(GetProp_String(getProp, getProp2, i, NArchive::NHandlerPropID::kAddExtension, addExt)) |
459 | item.AddExts(ext, addExt); | 453 | item.AddExts(ext, addExt); |
460 | 454 | ||
461 | GetProp_Bool(getProp, getProp2, i, NArchive::NHandlerPropID::kUpdate, item.UpdateEnabled); | 455 | GetProp_Bool(getProp, getProp2, i, NArchive::NHandlerPropID::kUpdate, item.UpdateEnabled); |
462 | bool flags_Defined = false; | 456 | bool flags_Defined = false; |
463 | RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kFlags, item.Flags, flags_Defined)); | 457 | RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kFlags, item.Flags, flags_Defined)) |
464 | item.NewInterface = flags_Defined; | 458 | item.NewInterface = flags_Defined; |
465 | if (!flags_Defined) // && item.UpdateEnabled | 459 | if (!flags_Defined) // && item.UpdateEnabled |
466 | { | 460 | { |
467 | // support for DLL version before 9.31: | 461 | // support for DLL version before 9.31: |
468 | for (unsigned j = 0; j < ARRAY_SIZE(kArcFlagsPars); j += 2) | 462 | for (unsigned j = 0; j < Z7_ARRAY_SIZE(kArcFlagsPars); j += 2) |
469 | { | 463 | { |
470 | bool val = false; | 464 | bool val = false; |
471 | GetProp_Bool(getProp, getProp2, i, kArcFlagsPars[j], val); | 465 | GetProp_Bool(getProp, getProp2, i, kArcFlagsPars[j], val); |
@@ -476,21 +470,21 @@ HRESULT CCodecs::LoadFormats() | |||
476 | 470 | ||
477 | { | 471 | { |
478 | bool defined = false; | 472 | bool defined = false; |
479 | RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kTimeFlags, item.TimeFlags, defined)); | 473 | RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kTimeFlags, item.TimeFlags, defined)) |
480 | } | 474 | } |
481 | 475 | ||
482 | CByteBuffer sig; | 476 | CByteBuffer sig; |
483 | RINOK(GetProp_RawData(getProp, getProp2, i, NArchive::NHandlerPropID::kSignature, sig)); | 477 | RINOK(GetProp_RawData(getProp, getProp2, i, NArchive::NHandlerPropID::kSignature, sig)) |
484 | if (sig.Size() != 0) | 478 | if (sig.Size() != 0) |
485 | item.Signatures.Add(sig); | 479 | item.Signatures.Add(sig); |
486 | else | 480 | else |
487 | { | 481 | { |
488 | RINOK(GetProp_RawData(getProp, getProp2, i, NArchive::NHandlerPropID::kMultiSignature, sig)); | 482 | RINOK(GetProp_RawData(getProp, getProp2, i, NArchive::NHandlerPropID::kMultiSignature, sig)) |
489 | ParseSignatures(sig, (unsigned)sig.Size(), item.Signatures); | 483 | ParseSignatures(sig, (unsigned)sig.Size(), item.Signatures); |
490 | } | 484 | } |
491 | 485 | ||
492 | bool signatureOffset_Defined; | 486 | bool signatureOffset_Defined; |
493 | RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kSignatureOffset, item.SignatureOffset, signatureOffset_Defined)); | 487 | RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kSignatureOffset, item.SignatureOffset, signatureOffset_Defined)) |
494 | 488 | ||
495 | // bool version_Defined; | 489 | // bool version_Defined; |
496 | // RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kVersion, item.Version, version_Defined)); | 490 | // RINOK(GetProp_UInt32(getProp, getProp2, i, NArchive::NHandlerPropID::kVersion, item.Version, version_Defined)); |
@@ -503,7 +497,7 @@ HRESULT CCodecs::LoadFormats() | |||
503 | return S_OK; | 497 | return S_OK; |
504 | } | 498 | } |
505 | 499 | ||
506 | #ifdef _7ZIP_LARGE_PAGES | 500 | #ifdef Z7_LARGE_PAGES |
507 | extern "C" | 501 | extern "C" |
508 | { | 502 | { |
509 | extern SIZE_T g_LargePageSize; | 503 | extern SIZE_T g_LargePageSize; |
@@ -513,12 +507,57 @@ extern "C" | |||
513 | 507 | ||
514 | void CCodecs::AddLastError(const FString &path) | 508 | void CCodecs::AddLastError(const FString &path) |
515 | { | 509 | { |
516 | HRESULT res = GetLastError_noZero_HRESULT(); | 510 | const HRESULT res = GetLastError_noZero_HRESULT(); |
517 | CCodecError &error = Errors.AddNew(); | 511 | CCodecError &error = Errors.AddNew(); |
518 | error.Path = path; | 512 | error.Path = path; |
519 | error.ErrorCode = res; | 513 | error.ErrorCode = res; |
520 | } | 514 | } |
521 | 515 | ||
516 | |||
517 | static bool IsSupportedDll(CCodecLib &lib) | ||
518 | { | ||
519 | MY_GET_FUNC_LOC ( | ||
520 | f_GetModuleProp, | ||
521 | Func_GetModuleProp, lib.Lib, | ||
522 | "GetModuleProp") | ||
523 | /* p7zip and 7-Zip before v23 used virtual destructor in IUnknown, | ||
524 | if _WIN32 is not defined */ | ||
525 | UInt32 flags = | ||
526 | #ifdef _WIN32 | ||
527 | NModuleInterfaceType::k_IUnknown_VirtDestructor_No; | ||
528 | #else | ||
529 | NModuleInterfaceType::k_IUnknown_VirtDestructor_Yes; | ||
530 | #endif | ||
531 | if (f_GetModuleProp) | ||
532 | { | ||
533 | { | ||
534 | NCOM::CPropVariant prop; | ||
535 | if (f_GetModuleProp(NModulePropID::kInterfaceType, &prop) == S_OK) | ||
536 | { | ||
537 | if (prop.vt == VT_UI4) | ||
538 | flags = prop.ulVal; | ||
539 | else if (prop.vt != VT_EMPTY) | ||
540 | return false; | ||
541 | } | ||
542 | } | ||
543 | { | ||
544 | NCOM::CPropVariant prop; | ||
545 | if (f_GetModuleProp(NModulePropID::kVersion, &prop) == S_OK) | ||
546 | { | ||
547 | if (prop.vt == VT_UI4) | ||
548 | lib.Version = prop.ulVal; | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | if ( | ||
553 | flags | ||
554 | // (flags & NModuleFlags::kMask) | ||
555 | != NModuleInterfaceType::k_IUnknown_VirtDestructor_ThisModule) | ||
556 | return false; | ||
557 | return true; | ||
558 | } | ||
559 | |||
560 | |||
522 | HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loadedOK) | 561 | HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loadedOK) |
523 | { | 562 | { |
524 | if (loadedOK) | 563 | if (loadedOK) |
@@ -537,7 +576,7 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded | |||
537 | // #define ERROR_BAD_EXE_FORMAT 193L | 576 | // #define ERROR_BAD_EXE_FORMAT 193L |
538 | */ | 577 | */ |
539 | // return GetLastError_noZero_HRESULT(); | 578 | // return GetLastError_noZero_HRESULT(); |
540 | DWORD lastError = GetLastError(); | 579 | const DWORD lastError = GetLastError(); |
541 | if (lastError != ERROR_BAD_EXE_FORMAT) | 580 | if (lastError != ERROR_BAD_EXE_FORMAT) |
542 | { | 581 | { |
543 | CCodecError &error = Errors.AddNew(); | 582 | CCodecError &error = Errors.AddNew(); |
@@ -558,20 +597,30 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded | |||
558 | bool used = false; | 597 | bool used = false; |
559 | // HRESULT res = S_OK; | 598 | // HRESULT res = S_OK; |
560 | 599 | ||
561 | if (lib.Lib.Load(dllPath)) | 600 | if (lib.Lib.Load(dllPath)) |
601 | { | ||
602 | if (!IsSupportedDll(lib)) | ||
603 | { | ||
604 | CCodecError &error = Errors.AddNew(); | ||
605 | error.Path = dllPath; | ||
606 | error.Message = "the module is not compatible with program"; | ||
607 | } | ||
608 | else | ||
562 | { | 609 | { |
563 | if (loadedOK) | 610 | if (loadedOK) |
564 | *loadedOK = true; | 611 | *loadedOK = true; |
612 | /* | ||
565 | #ifdef NEW_FOLDER_INTERFACE | 613 | #ifdef NEW_FOLDER_INTERFACE |
566 | lib.LoadIcons(); | 614 | lib.LoadIcons(); |
567 | #endif | 615 | #endif |
616 | */ | ||
568 | 617 | ||
569 | /* | 618 | /* |
570 | { | 619 | { |
571 | MY_GET_FUNC_LOC (_LibStartup, Func_LibStartup, lib.Lib.GetProc("LibStartup")); | 620 | MY_GET_FUNC_LOC (_libStartup, Func_libStartup, lib.Lib, "LibStartup") |
572 | if (_LibStartup) | 621 | if (_libStartup) |
573 | { | 622 | { |
574 | HRESULT res = _LibStartup(); | 623 | HRESULT res = _libStartup(); |
575 | if (res != 0) | 624 | if (res != 0) |
576 | { | 625 | { |
577 | CCodecError &error = Errors.AddNew(); | 626 | CCodecError &error = Errors.AddNew(); |
@@ -582,10 +631,10 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded | |||
582 | } | 631 | } |
583 | */ | 632 | */ |
584 | 633 | ||
585 | #ifdef _7ZIP_LARGE_PAGES | 634 | #ifdef Z7_LARGE_PAGES |
586 | if (g_LargePageSize != 0) | 635 | if (g_LargePageSize != 0) |
587 | { | 636 | { |
588 | MY_GET_FUNC_LOC (setLargePageMode, Func_SetLargePageMode, lib.Lib.GetProc("SetLargePageMode")); | 637 | MY_GET_FUNC_LOC (setLargePageMode, Func_SetLargePageMode, lib.Lib, "SetLargePageMode") |
589 | if (setLargePageMode) | 638 | if (setLargePageMode) |
590 | setLargePageMode(); | 639 | setLargePageMode(); |
591 | } | 640 | } |
@@ -593,14 +642,14 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded | |||
593 | 642 | ||
594 | if (CaseSensitive_Change) | 643 | if (CaseSensitive_Change) |
595 | { | 644 | { |
596 | MY_GET_FUNC_LOC (setCaseSensitive, Func_SetCaseSensitive, lib.Lib.GetProc("SetCaseSensitive")); | 645 | MY_GET_FUNC_LOC (setCaseSensitive, Func_SetCaseSensitive, lib.Lib, "SetCaseSensitive") |
597 | if (setCaseSensitive) | 646 | if (setCaseSensitive) |
598 | setCaseSensitive(CaseSensitive ? 1 : 0); | 647 | setCaseSensitive(CaseSensitive ? 1 : 0); |
599 | } | 648 | } |
600 | 649 | ||
601 | /* | 650 | /* |
602 | { | 651 | { |
603 | MY_GET_FUNC_LOC (setClientVersion, Func_SetClientVersion, lib.Lib.GetProc("SetClientVersion")); | 652 | MY_GET_FUNC_LOC (setClientVersion, Func_SetClientVersion, lib.Lib, "SetClientVersion") |
604 | if (setClientVersion) | 653 | if (setClientVersion) |
605 | { | 654 | { |
606 | // const UInt32 kVersion = (MY_VER_MAJOR << 16) | MY_VER_MINOR; | 655 | // const UInt32 kVersion = (MY_VER_MAJOR << 16) | MY_VER_MINOR; |
@@ -610,7 +659,7 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded | |||
610 | */ | 659 | */ |
611 | 660 | ||
612 | 661 | ||
613 | MY_GET_FUNC (lib.CreateObject, Func_CreateObject, lib.Lib.GetProc("CreateObject")); | 662 | MY_GET_FUNC (lib.CreateObject, Func_CreateObject, lib.Lib, "CreateObject") |
614 | { | 663 | { |
615 | unsigned startSize = Codecs.Size() + Hashers.Size(); | 664 | unsigned startSize = Codecs.Size() + Hashers.Size(); |
616 | HRESULT res = LoadCodecs(); | 665 | HRESULT res = LoadCodecs(); |
@@ -640,7 +689,8 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded | |||
640 | } | 689 | } |
641 | */ | 690 | */ |
642 | } | 691 | } |
643 | else | 692 | } |
693 | else | ||
644 | { | 694 | { |
645 | AddLastError(dllPath); | 695 | AddLastError(dllPath); |
646 | } | 696 | } |
@@ -686,7 +736,7 @@ HRESULT CCodecs::LoadDllsFromFolder(const FString &folderPath) | |||
686 | continue; | 736 | continue; |
687 | #endif | 737 | #endif |
688 | 738 | ||
689 | RINOK(LoadDll(folderPrefix + fi.Name, true)); | 739 | RINOK(LoadDll(folderPrefix + fi.Name, true)) |
690 | } | 740 | } |
691 | return S_OK; | 741 | return S_OK; |
692 | } | 742 | } |
@@ -714,18 +764,20 @@ void CCodecs::CloseLibs() | |||
714 | // OutputDebugStringA("~CloseLibs end"); | 764 | // OutputDebugStringA("~CloseLibs end"); |
715 | } | 765 | } |
716 | 766 | ||
717 | #endif // EXTERNAL_CODECS | 767 | #endif // Z7_EXTERNAL_CODECS |
718 | 768 | ||
719 | 769 | ||
720 | HRESULT CCodecs::Load() | 770 | HRESULT CCodecs::Load() |
721 | { | 771 | { |
772 | /* | ||
722 | #ifdef NEW_FOLDER_INTERFACE | 773 | #ifdef NEW_FOLDER_INTERFACE |
723 | InternalIcons.LoadIcons(g_hInstance); | 774 | InternalIcons.LoadIcons(g_hInstance); |
724 | #endif | 775 | #endif |
776 | */ | ||
725 | 777 | ||
726 | Formats.Clear(); | 778 | Formats.Clear(); |
727 | 779 | ||
728 | #ifdef EXTERNAL_CODECS | 780 | #ifdef Z7_EXTERNAL_CODECS |
729 | Errors.Clear(); | 781 | Errors.Clear(); |
730 | MainDll_ErrorPath.Empty(); | 782 | MainDll_ErrorPath.Empty(); |
731 | Codecs.Clear(); | 783 | Codecs.Clear(); |
@@ -751,7 +803,7 @@ HRESULT CCodecs::Load() | |||
751 | item.AddExts(e, ae); | 803 | item.AddExts(e, ae); |
752 | } | 804 | } |
753 | 805 | ||
754 | #ifndef _SFX | 806 | #ifndef Z7_SFX |
755 | 807 | ||
756 | item.CreateOutArchive = arc.CreateOutArchive; | 808 | item.CreateOutArchive = arc.CreateOutArchive; |
757 | item.UpdateEnabled = (arc.CreateOutArchive != NULL); | 809 | item.UpdateEnabled = (arc.CreateOutArchive != NULL); |
@@ -774,16 +826,16 @@ HRESULT CCodecs::Load() | |||
774 | 826 | ||
775 | // printf("\nLoad codecs \n"); | 827 | // printf("\nLoad codecs \n"); |
776 | 828 | ||
777 | #ifdef EXTERNAL_CODECS | 829 | #ifdef Z7_EXTERNAL_CODECS |
778 | const FString baseFolder = GetBaseFolderPrefixFromRegistry(); | 830 | const FString baseFolder = GetBaseFolderPrefixFromRegistry(); |
779 | { | 831 | { |
780 | bool loadedOK; | 832 | bool loadedOK; |
781 | RINOK(LoadDll(baseFolder + kMainDll, false, &loadedOK)); | 833 | RINOK(LoadDll(baseFolder + kMainDll, false, &loadedOK)) |
782 | if (!loadedOK) | 834 | if (!loadedOK) |
783 | MainDll_ErrorPath = kMainDll; | 835 | MainDll_ErrorPath = kMainDll; |
784 | } | 836 | } |
785 | RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName)); | 837 | RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName)) |
786 | RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName)); | 838 | RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName)) |
787 | 839 | ||
788 | NeedSetLibCodecs = true; | 840 | NeedSetLibCodecs = true; |
789 | 841 | ||
@@ -806,10 +858,10 @@ HRESULT CCodecs::Load() | |||
806 | FOR_VECTOR(i, Libs) | 858 | FOR_VECTOR(i, Libs) |
807 | { | 859 | { |
808 | CCodecLib &lib = Libs[i]; | 860 | CCodecLib &lib = Libs[i]; |
809 | MY_GET_FUNC (lib.SetCodecs, Func_SetCodecs, lib.Lib.GetProc("SetCodecs")); | 861 | MY_GET_FUNC (lib.SetCodecs, Func_SetCodecs, lib.Lib, "SetCodecs") |
810 | if (lib.SetCodecs) | 862 | if (lib.SetCodecs) |
811 | { | 863 | { |
812 | RINOK(lib.SetCodecs(this)); | 864 | RINOK(lib.SetCodecs(this)) |
813 | } | 865 | } |
814 | } | 866 | } |
815 | } | 867 | } |
@@ -821,7 +873,7 @@ HRESULT CCodecs::Load() | |||
821 | return S_OK; | 873 | return S_OK; |
822 | } | 874 | } |
823 | 875 | ||
824 | #ifndef _SFX | 876 | #ifndef Z7_SFX |
825 | 877 | ||
826 | int CCodecs::FindFormatForArchiveName(const UString &arcPath) const | 878 | int CCodecs::FindFormatForArchiveName(const UString &arcPath) const |
827 | { | 879 | { |
@@ -887,60 +939,10 @@ bool CCodecs::FindFormatForArchiveType(const UString &arcType, CIntVector &forma | |||
887 | return true; | 939 | return true; |
888 | } | 940 | } |
889 | 941 | ||
890 | #endif // _SFX | 942 | #endif // Z7_SFX |
891 | |||
892 | |||
893 | #ifdef NEW_FOLDER_INTERFACE | ||
894 | |||
895 | void CCodecIcons::LoadIcons(HMODULE m) | ||
896 | { | ||
897 | UString iconTypes; | ||
898 | MyLoadString(m, kIconTypesResId, iconTypes); | ||
899 | UStringVector pairs; | ||
900 | SplitString(iconTypes, pairs); | ||
901 | FOR_VECTOR (i, pairs) | ||
902 | { | ||
903 | const UString &s = pairs[i]; | ||
904 | int pos = s.Find(L':'); | ||
905 | CIconPair iconPair; | ||
906 | iconPair.IconIndex = -1; | ||
907 | if (pos < 0) | ||
908 | pos = (int)s.Len(); | ||
909 | else | ||
910 | { | ||
911 | const UString num = s.Ptr((unsigned)pos + 1); | ||
912 | if (!num.IsEmpty()) | ||
913 | { | ||
914 | const wchar_t *end; | ||
915 | iconPair.IconIndex = (int)ConvertStringToUInt32(num, &end); | ||
916 | if (*end != 0) | ||
917 | continue; | ||
918 | } | ||
919 | } | ||
920 | iconPair.Ext = s.Left((unsigned)pos); | ||
921 | IconPairs.Add(iconPair); | ||
922 | } | ||
923 | } | ||
924 | |||
925 | bool CCodecIcons::FindIconIndex(const UString &ext, int &iconIndex) const | ||
926 | { | ||
927 | iconIndex = -1; | ||
928 | FOR_VECTOR (i, IconPairs) | ||
929 | { | ||
930 | const CIconPair &pair = IconPairs[i]; | ||
931 | if (ext.IsEqualTo_NoCase(pair.Ext)) | ||
932 | { | ||
933 | iconIndex = pair.IconIndex; | ||
934 | return true; | ||
935 | } | ||
936 | } | ||
937 | return false; | ||
938 | } | ||
939 | |||
940 | #endif // NEW_FOLDER_INTERFACE | ||
941 | 943 | ||
942 | 944 | ||
943 | #ifdef EXTERNAL_CODECS | 945 | #ifdef Z7_EXTERNAL_CODECS |
944 | 946 | ||
945 | // #define EXPORT_CODECS | 947 | // #define EXPORT_CODECS |
946 | 948 | ||
@@ -964,24 +966,24 @@ STDAPI GetHasherProp(UInt32 codecIndex, PROPID propID, PROPVARIANT *value); | |||
964 | 966 | ||
965 | #endif // EXPORT_CODECS | 967 | #endif // EXPORT_CODECS |
966 | 968 | ||
967 | STDMETHODIMP CCodecs::GetNumMethods(UInt32 *numMethods) | 969 | Z7_COM7F_IMF(CCodecs::GetNumMethods(UInt32 *numMethods)) |
968 | { | 970 | { |
969 | *numMethods = NUM_EXPORT_CODECS | 971 | *numMethods = NUM_EXPORT_CODECS |
970 | #ifdef EXTERNAL_CODECS | 972 | #ifdef Z7_EXTERNAL_CODECS |
971 | + Codecs.Size() | 973 | + Codecs.Size() |
972 | #endif | 974 | #endif |
973 | ; | 975 | ; |
974 | return S_OK; | 976 | return S_OK; |
975 | } | 977 | } |
976 | 978 | ||
977 | STDMETHODIMP CCodecs::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) | 979 | Z7_COM7F_IMF(CCodecs::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)) |
978 | { | 980 | { |
979 | #ifdef EXPORT_CODECS | 981 | #ifdef EXPORT_CODECS |
980 | if (index < g_NumCodecs) | 982 | if (index < g_NumCodecs) |
981 | return GetMethodProperty(index, propID, value); | 983 | return GetMethodProperty(index, propID, value); |
982 | #endif | 984 | #endif |
983 | 985 | ||
984 | #ifdef EXTERNAL_CODECS | 986 | #ifdef Z7_EXTERNAL_CODECS |
985 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; | 987 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; |
986 | 988 | ||
987 | if (propID == NMethodPropID::kDecoderIsAssigned || | 989 | if (propID == NMethodPropID::kDecoderIsAssigned || |
@@ -1010,14 +1012,14 @@ STDMETHODIMP CCodecs::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *valu | |||
1010 | #endif | 1012 | #endif |
1011 | } | 1013 | } |
1012 | 1014 | ||
1013 | STDMETHODIMP CCodecs::CreateDecoder(UInt32 index, const GUID *iid, void **coder) | 1015 | Z7_COM7F_IMF(CCodecs::CreateDecoder(UInt32 index, const GUID *iid, void **coder)) |
1014 | { | 1016 | { |
1015 | #ifdef EXPORT_CODECS | 1017 | #ifdef EXPORT_CODECS |
1016 | if (index < g_NumCodecs) | 1018 | if (index < g_NumCodecs) |
1017 | return CreateDecoder(index, iid, coder); | 1019 | return CreateDecoder(index, iid, coder); |
1018 | #endif | 1020 | #endif |
1019 | 1021 | ||
1020 | #ifdef EXTERNAL_CODECS | 1022 | #ifdef Z7_EXTERNAL_CODECS |
1021 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; | 1023 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; |
1022 | if (ci.DecoderIsAssigned) | 1024 | if (ci.DecoderIsAssigned) |
1023 | { | 1025 | { |
@@ -1033,14 +1035,14 @@ STDMETHODIMP CCodecs::CreateDecoder(UInt32 index, const GUID *iid, void **coder) | |||
1033 | #endif | 1035 | #endif |
1034 | } | 1036 | } |
1035 | 1037 | ||
1036 | STDMETHODIMP CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder) | 1038 | Z7_COM7F_IMF(CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder)) |
1037 | { | 1039 | { |
1038 | #ifdef EXPORT_CODECS | 1040 | #ifdef EXPORT_CODECS |
1039 | if (index < g_NumCodecs) | 1041 | if (index < g_NumCodecs) |
1040 | return CreateEncoder(index, iid, coder); | 1042 | return CreateEncoder(index, iid, coder); |
1041 | #endif | 1043 | #endif |
1042 | 1044 | ||
1043 | #ifdef EXTERNAL_CODECS | 1045 | #ifdef Z7_EXTERNAL_CODECS |
1044 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; | 1046 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; |
1045 | if (ci.EncoderIsAssigned) | 1047 | if (ci.EncoderIsAssigned) |
1046 | { | 1048 | { |
@@ -1057,23 +1059,23 @@ STDMETHODIMP CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder) | |||
1057 | } | 1059 | } |
1058 | 1060 | ||
1059 | 1061 | ||
1060 | STDMETHODIMP_(UInt32) CCodecs::GetNumHashers() | 1062 | Z7_COM7F_IMF2(UInt32, CCodecs::GetNumHashers()) |
1061 | { | 1063 | { |
1062 | return NUM_EXPORT_HASHERS | 1064 | return NUM_EXPORT_HASHERS |
1063 | #ifdef EXTERNAL_CODECS | 1065 | #ifdef Z7_EXTERNAL_CODECS |
1064 | + Hashers.Size() | 1066 | + Hashers.Size() |
1065 | #endif | 1067 | #endif |
1066 | ; | 1068 | ; |
1067 | } | 1069 | } |
1068 | 1070 | ||
1069 | STDMETHODIMP CCodecs::GetHasherProp(UInt32 index, PROPID propID, PROPVARIANT *value) | 1071 | Z7_COM7F_IMF(CCodecs::GetHasherProp(UInt32 index, PROPID propID, PROPVARIANT *value)) |
1070 | { | 1072 | { |
1071 | #ifdef EXPORT_CODECS | 1073 | #ifdef EXPORT_CODECS |
1072 | if (index < g_NumHashers) | 1074 | if (index < g_NumHashers) |
1073 | return ::GetHasherProp(index, propID, value); | 1075 | return ::GetHasherProp(index, propID, value); |
1074 | #endif | 1076 | #endif |
1075 | 1077 | ||
1076 | #ifdef EXTERNAL_CODECS | 1078 | #ifdef Z7_EXTERNAL_CODECS |
1077 | const CDllHasherInfo &ci = Hashers[index - NUM_EXPORT_HASHERS]; | 1079 | const CDllHasherInfo &ci = Hashers[index - NUM_EXPORT_HASHERS]; |
1078 | return Libs[ci.LibIndex].ComHashers->GetHasherProp(ci.HasherIndex, propID, value); | 1080 | return Libs[ci.LibIndex].ComHashers->GetHasherProp(ci.HasherIndex, propID, value); |
1079 | #else | 1081 | #else |
@@ -1081,13 +1083,13 @@ STDMETHODIMP CCodecs::GetHasherProp(UInt32 index, PROPID propID, PROPVARIANT *va | |||
1081 | #endif | 1083 | #endif |
1082 | } | 1084 | } |
1083 | 1085 | ||
1084 | STDMETHODIMP CCodecs::CreateHasher(UInt32 index, IHasher **hasher) | 1086 | Z7_COM7F_IMF(CCodecs::CreateHasher(UInt32 index, IHasher **hasher)) |
1085 | { | 1087 | { |
1086 | #ifdef EXPORT_CODECS | 1088 | #ifdef EXPORT_CODECS |
1087 | if (index < g_NumHashers) | 1089 | if (index < g_NumHashers) |
1088 | return CreateHasher(index, hasher); | 1090 | return CreateHasher(index, hasher); |
1089 | #endif | 1091 | #endif |
1090 | #ifdef EXTERNAL_CODECS | 1092 | #ifdef Z7_EXTERNAL_CODECS |
1091 | const CDllHasherInfo &ci = Hashers[index - NUM_EXPORT_HASHERS]; | 1093 | const CDllHasherInfo &ci = Hashers[index - NUM_EXPORT_HASHERS]; |
1092 | return Libs[ci.LibIndex].ComHashers->CreateHasher(ci.HasherIndex, hasher); | 1094 | return Libs[ci.LibIndex].ComHashers->CreateHasher(ci.HasherIndex, hasher); |
1093 | #else | 1095 | #else |
@@ -1102,7 +1104,7 @@ int CCodecs::GetCodec_LibIndex(UInt32 index) const | |||
1102 | return -1; | 1104 | return -1; |
1103 | #endif | 1105 | #endif |
1104 | 1106 | ||
1105 | #ifdef EXTERNAL_CODECS | 1107 | #ifdef Z7_EXTERNAL_CODECS |
1106 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; | 1108 | const CDllCodecInfo &ci = Codecs[index - NUM_EXPORT_CODECS]; |
1107 | return (int)ci.LibIndex; | 1109 | return (int)ci.LibIndex; |
1108 | #else | 1110 | #else |
@@ -1117,7 +1119,7 @@ int CCodecs::GetHasherLibIndex(UInt32 index) | |||
1117 | return -1; | 1119 | return -1; |
1118 | #endif | 1120 | #endif |
1119 | 1121 | ||
1120 | #ifdef EXTERNAL_CODECS | 1122 | #ifdef Z7_EXTERNAL_CODECS |
1121 | const CDllHasherInfo &ci = Hashers[index - NUM_EXPORT_HASHERS]; | 1123 | const CDllHasherInfo &ci = Hashers[index - NUM_EXPORT_HASHERS]; |
1122 | return (int)ci.LibIndex; | 1124 | return (int)ci.LibIndex; |
1123 | #else | 1125 | #else |
@@ -1140,7 +1142,7 @@ bool CCodecs::GetCodec_DecoderIsAssigned(UInt32 index) const | |||
1140 | } | 1142 | } |
1141 | #endif | 1143 | #endif |
1142 | 1144 | ||
1143 | #ifdef EXTERNAL_CODECS | 1145 | #ifdef Z7_EXTERNAL_CODECS |
1144 | return Codecs[index - NUM_EXPORT_CODECS].DecoderIsAssigned; | 1146 | return Codecs[index - NUM_EXPORT_CODECS].DecoderIsAssigned; |
1145 | #else | 1147 | #else |
1146 | return false; | 1148 | return false; |
@@ -1163,7 +1165,7 @@ bool CCodecs::GetCodec_EncoderIsAssigned(UInt32 index) const | |||
1163 | } | 1165 | } |
1164 | #endif | 1166 | #endif |
1165 | 1167 | ||
1166 | #ifdef EXTERNAL_CODECS | 1168 | #ifdef Z7_EXTERNAL_CODECS |
1167 | return Codecs[index - NUM_EXPORT_CODECS].EncoderIsAssigned; | 1169 | return Codecs[index - NUM_EXPORT_CODECS].EncoderIsAssigned; |
1168 | #else | 1170 | #else |
1169 | return false; | 1171 | return false; |
@@ -1190,7 +1192,7 @@ bool CCodecs::GetCodec_IsFilter(UInt32 index, bool &isAssigned) const | |||
1190 | } | 1192 | } |
1191 | #endif | 1193 | #endif |
1192 | 1194 | ||
1193 | #ifdef EXTERNAL_CODECS | 1195 | #ifdef Z7_EXTERNAL_CODECS |
1194 | { | 1196 | { |
1195 | const CDllCodecInfo &c = Codecs[index - NUM_EXPORT_CODECS]; | 1197 | const CDllCodecInfo &c = Codecs[index - NUM_EXPORT_CODECS]; |
1196 | isAssigned = c.IsFilter_Assigned; | 1198 | isAssigned = c.IsFilter_Assigned; |
@@ -1217,7 +1219,7 @@ UInt32 CCodecs::GetCodec_NumStreams(UInt32 index) | |||
1217 | HRESULT CCodecs::GetCodec_Id(UInt32 index, UInt64 &id) | 1219 | HRESULT CCodecs::GetCodec_Id(UInt32 index, UInt64 &id) |
1218 | { | 1220 | { |
1219 | NCOM::CPropVariant prop; | 1221 | NCOM::CPropVariant prop; |
1220 | RINOK(GetProperty(index, NMethodPropID::kID, &prop)); | 1222 | RINOK(GetProperty(index, NMethodPropID::kID, &prop)) |
1221 | if (prop.vt != VT_UI8) | 1223 | if (prop.vt != VT_UI8) |
1222 | return E_INVALIDARG; | 1224 | return E_INVALIDARG; |
1223 | id = prop.uhVal.QuadPart; | 1225 | id = prop.uhVal.QuadPart; |
@@ -1286,9 +1288,9 @@ void CCodecs::GetCodecsErrorMessage(UString &s) | |||
1286 | } | 1288 | } |
1287 | } | 1289 | } |
1288 | 1290 | ||
1289 | #endif // EXTERNAL_CODECS | 1291 | #endif // Z7_EXTERNAL_CODECS |
1290 | 1292 | ||
1291 | #ifndef _SFX | 1293 | #ifndef Z7_SFX |
1292 | 1294 | ||
1293 | extern unsigned g_NumCodecs; | 1295 | extern unsigned g_NumCodecs; |
1294 | extern const CCodecInfo *g_Codecs[]; | 1296 | extern const CCodecInfo *g_Codecs[]; |
@@ -1311,7 +1313,7 @@ void CCodecs::Get_CodecsInfoUser_Vector(CObjectVector<CCodecInfoUser> &v) | |||
1311 | } | 1313 | } |
1312 | 1314 | ||
1313 | 1315 | ||
1314 | #ifdef EXTERNAL_CODECS | 1316 | #ifdef Z7_EXTERNAL_CODECS |
1315 | { | 1317 | { |
1316 | UInt32 numMethods; | 1318 | UInt32 numMethods; |
1317 | if (GetNumMethods(&numMethods) == S_OK) | 1319 | if (GetNumMethods(&numMethods) == S_OK) |
diff --git a/CPP/7zip/UI/Common/LoadCodecs.h b/CPP/7zip/UI/Common/LoadCodecs.h index 50fb9f8..a81bb5c 100644 --- a/CPP/7zip/UI/Common/LoadCodecs.h +++ b/CPP/7zip/UI/Common/LoadCodecs.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // LoadCodecs.h | 1 | // LoadCodecs.h |
2 | 2 | ||
3 | #ifndef __LOAD_CODECS_H | 3 | #ifndef ZIP7_INC_LOAD_CODECS_H |
4 | #define __LOAD_CODECS_H | 4 | #define ZIP7_INC_LOAD_CODECS_H |
5 | 5 | ||
6 | /* | 6 | /* |
7 | Client application uses LoadCodecs.* to load plugins to | 7 | Client application uses LoadCodecs.* to load plugins to |
@@ -10,26 +10,26 @@ CCodecs object, that contains 3 lists of plugins: | |||
10 | 2) Codecs - external codecs | 10 | 2) Codecs - external codecs |
11 | 3) Hashers - external hashers | 11 | 3) Hashers - external hashers |
12 | 12 | ||
13 | EXTERNAL_CODECS | 13 | Z7_EXTERNAL_CODECS |
14 | --------------- | 14 | --------------- |
15 | 15 | ||
16 | if EXTERNAL_CODECS is defined, then the code tries to load external | 16 | if Z7_EXTERNAL_CODECS is defined, then the code tries to load external |
17 | plugins from DLL files (shared libraries). | 17 | plugins from DLL files (shared libraries). |
18 | 18 | ||
19 | There are two types of executables in 7-Zip: | 19 | There are two types of executables in 7-Zip: |
20 | 20 | ||
21 | 1) Executable that uses external plugins must be compiled | 21 | 1) Executable that uses external plugins must be compiled |
22 | with EXTERNAL_CODECS defined: | 22 | with Z7_EXTERNAL_CODECS defined: |
23 | - 7z.exe, 7zG.exe, 7zFM.exe | 23 | - 7z.exe, 7zG.exe, 7zFM.exe |
24 | 24 | ||
25 | Note: EXTERNAL_CODECS is used also in CPP/7zip/Common/CreateCoder.h | 25 | Note: Z7_EXTERNAL_CODECS is used also in CPP/7zip/Common/CreateCoder.h |
26 | that code is used in plugin module (7z.dll). | 26 | that code is used in plugin module (7z.dll). |
27 | 27 | ||
28 | 2) Standalone modules are compiled without EXTERNAL_CODECS: | 28 | 2) Standalone modules are compiled without Z7_EXTERNAL_CODECS: |
29 | - SFX modules: 7z.sfx, 7zCon.sfx | 29 | - SFX modules: 7z.sfx, 7zCon.sfx |
30 | - standalone versions of console 7-Zip: 7za.exe, 7zr.exe | 30 | - standalone versions of console 7-Zip: 7za.exe, 7zr.exe |
31 | 31 | ||
32 | if EXTERNAL_CODECS is defined, CCodecs class implements interfaces: | 32 | if Z7_EXTERNAL_CODECS is defined, CCodecs class implements interfaces: |
33 | - ICompressCodecsInfo : for Codecs | 33 | - ICompressCodecsInfo : for Codecs |
34 | - IHashers : for Hashers | 34 | - IHashers : for Hashers |
35 | 35 | ||
@@ -51,7 +51,7 @@ EXTERNAL_CODECS | |||
51 | #include "../../../Common/MyString.h" | 51 | #include "../../../Common/MyString.h" |
52 | #include "../../../Common/ComTry.h" | 52 | #include "../../../Common/ComTry.h" |
53 | 53 | ||
54 | #ifdef EXTERNAL_CODECS | 54 | #ifdef Z7_EXTERNAL_CODECS |
55 | #include "../../../Windows/DLL.h" | 55 | #include "../../../Windows/DLL.h" |
56 | #endif | 56 | #endif |
57 | 57 | ||
@@ -60,7 +60,7 @@ EXTERNAL_CODECS | |||
60 | #include "../../Archive/IArchive.h" | 60 | #include "../../Archive/IArchive.h" |
61 | 61 | ||
62 | 62 | ||
63 | #ifdef EXTERNAL_CODECS | 63 | #ifdef Z7_EXTERNAL_CODECS |
64 | 64 | ||
65 | struct CDllCodecInfo | 65 | struct CDllCodecInfo |
66 | { | 66 | { |
@@ -104,19 +104,21 @@ struct CArcInfoEx | |||
104 | UString Name; | 104 | UString Name; |
105 | CObjectVector<CArcExtInfo> Exts; | 105 | CObjectVector<CArcExtInfo> Exts; |
106 | 106 | ||
107 | #ifndef _SFX | 107 | #ifndef Z7_SFX |
108 | Func_CreateOutArchive CreateOutArchive; | 108 | Func_CreateOutArchive CreateOutArchive; |
109 | bool UpdateEnabled; | 109 | bool UpdateEnabled; |
110 | bool NewInterface; | 110 | bool NewInterface; |
111 | // UInt32 Version; | 111 | // UInt32 Version; |
112 | UInt32 SignatureOffset; | 112 | UInt32 SignatureOffset; |
113 | CObjectVector<CByteBuffer> Signatures; | 113 | CObjectVector<CByteBuffer> Signatures; |
114 | /* | ||
114 | #ifdef NEW_FOLDER_INTERFACE | 115 | #ifdef NEW_FOLDER_INTERFACE |
115 | UStringVector AssociateExts; | 116 | UStringVector AssociateExts; |
116 | #endif | 117 | #endif |
118 | */ | ||
117 | #endif | 119 | #endif |
118 | 120 | ||
119 | #ifdef EXTERNAL_CODECS | 121 | #ifdef Z7_EXTERNAL_CODECS |
120 | int LibIndex; | 122 | int LibIndex; |
121 | UInt32 FormatIndex; | 123 | UInt32 FormatIndex; |
122 | CLSID ClassID; | 124 | CLSID ClassID; |
@@ -124,10 +126,10 @@ struct CArcInfoEx | |||
124 | 126 | ||
125 | int Compare(const CArcInfoEx &a) const | 127 | int Compare(const CArcInfoEx &a) const |
126 | { | 128 | { |
127 | int res = Name.Compare(a.Name); | 129 | const int res = Name.Compare(a.Name); |
128 | if (res != 0) | 130 | if (res != 0) |
129 | return res; | 131 | return res; |
130 | #ifdef EXTERNAL_CODECS | 132 | #ifdef Z7_EXTERNAL_CODECS |
131 | return MyCompare(LibIndex, a.LibIndex); | 133 | return MyCompare(LibIndex, a.LibIndex); |
132 | #else | 134 | #else |
133 | return 0; | 135 | return 0; |
@@ -192,6 +194,7 @@ struct CArcInfoEx | |||
192 | bool Is_Tar() const { return Name.IsEqualTo_Ascii_NoCase("tar"); } | 194 | bool Is_Tar() const { return Name.IsEqualTo_Ascii_NoCase("tar"); } |
193 | bool Is_Zip() const { return Name.IsEqualTo_Ascii_NoCase("zip"); } | 195 | bool Is_Zip() const { return Name.IsEqualTo_Ascii_NoCase("zip"); } |
194 | bool Is_Rar() const { return Name.IsEqualTo_Ascii_NoCase("rar"); } | 196 | bool Is_Rar() const { return Name.IsEqualTo_Ascii_NoCase("rar"); } |
197 | bool Is_Zstd() const { return Name.IsEqualTo_Ascii_NoCase("zstd"); } | ||
195 | 198 | ||
196 | /* | 199 | /* |
197 | UString GetAllExtensions() const | 200 | UString GetAllExtensions() const |
@@ -200,7 +203,7 @@ struct CArcInfoEx | |||
200 | for (int i = 0; i < Exts.Size(); i++) | 203 | for (int i = 0; i < Exts.Size(); i++) |
201 | { | 204 | { |
202 | if (i > 0) | 205 | if (i > 0) |
203 | s += ' '; | 206 | s.Add_Space(); |
204 | s += Exts[i].Ext; | 207 | s += Exts[i].Ext; |
205 | } | 208 | } |
206 | return s; | 209 | return s; |
@@ -215,42 +218,23 @@ struct CArcInfoEx | |||
215 | TimeFlags(0), | 218 | TimeFlags(0), |
216 | CreateInArchive(NULL), | 219 | CreateInArchive(NULL), |
217 | IsArcFunc(NULL) | 220 | IsArcFunc(NULL) |
218 | #ifndef _SFX | 221 | #ifndef Z7_SFX |
219 | , CreateOutArchive(NULL) | 222 | , CreateOutArchive(NULL) |
220 | , UpdateEnabled(false) | 223 | , UpdateEnabled(false) |
221 | , NewInterface(false) | 224 | , NewInterface(false) |
222 | // , Version(0) | 225 | // , Version(0) |
223 | , SignatureOffset(0) | 226 | , SignatureOffset(0) |
224 | #endif | 227 | #endif |
225 | #ifdef EXTERNAL_CODECS | 228 | #ifdef Z7_EXTERNAL_CODECS |
226 | , LibIndex(-1) | 229 | , LibIndex(-1) |
227 | #endif | 230 | #endif |
228 | {} | 231 | {} |
229 | }; | 232 | }; |
230 | 233 | ||
231 | #ifdef NEW_FOLDER_INTERFACE | ||
232 | |||
233 | struct CCodecIcons | ||
234 | { | ||
235 | struct CIconPair | ||
236 | { | ||
237 | UString Ext; | ||
238 | int IconIndex; | ||
239 | }; | ||
240 | CObjectVector<CIconPair> IconPairs; | ||
241 | |||
242 | void LoadIcons(HMODULE m); | ||
243 | bool FindIconIndex(const UString &ext, int &iconIndex) const; | ||
244 | }; | ||
245 | |||
246 | #endif | ||
247 | 234 | ||
248 | #ifdef EXTERNAL_CODECS | 235 | #ifdef Z7_EXTERNAL_CODECS |
249 | 236 | ||
250 | struct CCodecLib | 237 | struct CCodecLib |
251 | #ifdef NEW_FOLDER_INTERFACE | ||
252 | : public CCodecIcons | ||
253 | #endif | ||
254 | { | 238 | { |
255 | NWindows::NDLL::CLibrary Lib; | 239 | NWindows::NDLL::CLibrary Lib; |
256 | FString Path; | 240 | FString Path; |
@@ -262,17 +246,23 @@ struct CCodecLib | |||
262 | Func_SetCodecs SetCodecs; | 246 | Func_SetCodecs SetCodecs; |
263 | 247 | ||
264 | CMyComPtr<IHashers> ComHashers; | 248 | CMyComPtr<IHashers> ComHashers; |
249 | |||
250 | UInt32 Version; | ||
265 | 251 | ||
252 | /* | ||
266 | #ifdef NEW_FOLDER_INTERFACE | 253 | #ifdef NEW_FOLDER_INTERFACE |
267 | void LoadIcons() { CCodecIcons::LoadIcons((HMODULE)Lib); } | 254 | CCodecIcons CodecIcons; |
255 | void LoadIcons() { CodecIcons.LoadIcons((HMODULE)Lib); } | ||
268 | #endif | 256 | #endif |
257 | */ | ||
269 | 258 | ||
270 | CCodecLib(): | 259 | CCodecLib(): |
271 | CreateObject(NULL), | 260 | CreateObject(NULL), |
272 | GetMethodProperty(NULL), | 261 | GetMethodProperty(NULL), |
273 | CreateDecoder(NULL), | 262 | CreateDecoder(NULL), |
274 | CreateEncoder(NULL), | 263 | CreateEncoder(NULL), |
275 | SetCodecs(NULL) | 264 | SetCodecs(NULL), |
265 | Version(0) | ||
276 | {} | 266 | {} |
277 | }; | 267 | }; |
278 | 268 | ||
@@ -301,8 +291,8 @@ struct CCodecInfoUser | |||
301 | }; | 291 | }; |
302 | 292 | ||
303 | 293 | ||
304 | class CCodecs: | 294 | class CCodecs Z7_final: |
305 | #ifdef EXTERNAL_CODECS | 295 | #ifdef Z7_EXTERNAL_CODECS |
306 | public ICompressCodecsInfo, | 296 | public ICompressCodecsInfo, |
307 | public IHashers, | 297 | public IHashers, |
308 | #else | 298 | #else |
@@ -310,9 +300,15 @@ class CCodecs: | |||
310 | #endif | 300 | #endif |
311 | public CMyUnknownImp | 301 | public CMyUnknownImp |
312 | { | 302 | { |
313 | CLASS_NO_COPY(CCodecs); | 303 | #ifdef Z7_EXTERNAL_CODECS |
304 | Z7_IFACES_IMP_UNK_2(ICompressCodecsInfo, IHashers) | ||
305 | #else | ||
306 | Z7_COM_UNKNOWN_IMP_0 | ||
307 | #endif // Z7_EXTERNAL_CODECS | ||
308 | |||
309 | Z7_CLASS_NO_COPY(CCodecs) | ||
314 | public: | 310 | public: |
315 | #ifdef EXTERNAL_CODECS | 311 | #ifdef Z7_EXTERNAL_CODECS |
316 | 312 | ||
317 | CObjectVector<CCodecLib> Libs; | 313 | CObjectVector<CCodecLib> Libs; |
318 | FString MainDll_ErrorPath; | 314 | FString MainDll_ErrorPath; |
@@ -323,7 +319,7 @@ public: | |||
323 | 319 | ||
324 | class CReleaser | 320 | class CReleaser |
325 | { | 321 | { |
326 | CLASS_NO_COPY(CReleaser); | 322 | Z7_CLASS_NO_COPY(CReleaser) |
327 | 323 | ||
328 | /* CCodecsReleaser object releases CCodecs links. | 324 | /* CCodecsReleaser object releases CCodecs links. |
329 | 1) CCodecs is COM object that is deleted when all links to that object will be released/ | 325 | 1) CCodecs is COM object that is deleted when all links to that object will be released/ |
@@ -352,13 +348,15 @@ public: | |||
352 | 348 | ||
353 | #endif | 349 | #endif |
354 | 350 | ||
351 | /* | ||
355 | #ifdef NEW_FOLDER_INTERFACE | 352 | #ifdef NEW_FOLDER_INTERFACE |
356 | CCodecIcons InternalIcons; | 353 | CCodecIcons InternalIcons; |
357 | #endif | 354 | #endif |
355 | */ | ||
358 | 356 | ||
359 | CObjectVector<CArcInfoEx> Formats; | 357 | CObjectVector<CArcInfoEx> Formats; |
360 | 358 | ||
361 | #ifdef EXTERNAL_CODECS | 359 | #ifdef Z7_EXTERNAL_CODECS |
362 | CRecordVector<CDllCodecInfo> Codecs; | 360 | CRecordVector<CDllCodecInfo> Codecs; |
363 | CRecordVector<CDllHasherInfo> Hashers; | 361 | CRecordVector<CDllHasherInfo> Hashers; |
364 | #endif | 362 | #endif |
@@ -367,7 +365,7 @@ public: | |||
367 | bool CaseSensitive; | 365 | bool CaseSensitive; |
368 | 366 | ||
369 | CCodecs(): | 367 | CCodecs(): |
370 | #ifdef EXTERNAL_CODECS | 368 | #ifdef Z7_EXTERNAL_CODECS |
371 | NeedSetLibCodecs(true), | 369 | NeedSetLibCodecs(true), |
372 | #endif | 370 | #endif |
373 | CaseSensitive_Change(false), | 371 | CaseSensitive_Change(false), |
@@ -386,34 +384,14 @@ public: | |||
386 | 384 | ||
387 | HRESULT Load(); | 385 | HRESULT Load(); |
388 | 386 | ||
389 | #ifndef _SFX | 387 | #ifndef Z7_SFX |
390 | int FindFormatForArchiveName(const UString &arcPath) const; | 388 | int FindFormatForArchiveName(const UString &arcPath) const; |
391 | int FindFormatForExtension(const UString &ext) const; | 389 | int FindFormatForExtension(const UString &ext) const; |
392 | int FindFormatForArchiveType(const UString &arcType) const; | 390 | int FindFormatForArchiveType(const UString &arcType) const; |
393 | bool FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndices) const; | 391 | bool FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndices) const; |
394 | #endif | 392 | #endif |
395 | 393 | ||
396 | #ifdef EXTERNAL_CODECS | 394 | #ifdef Z7_EXTERNAL_CODECS |
397 | |||
398 | MY_UNKNOWN_IMP2(ICompressCodecsInfo, IHashers) | ||
399 | |||
400 | STDMETHOD(GetNumMethods)(UInt32 *numMethods); | ||
401 | STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value); | ||
402 | STDMETHOD(CreateDecoder)(UInt32 index, const GUID *iid, void **coder); | ||
403 | STDMETHOD(CreateEncoder)(UInt32 index, const GUID *iid, void **coder); | ||
404 | |||
405 | STDMETHOD_(UInt32, GetNumHashers)(); | ||
406 | STDMETHOD(GetHasherProp)(UInt32 index, PROPID propID, PROPVARIANT *value); | ||
407 | STDMETHOD(CreateHasher)(UInt32 index, IHasher **hasher); | ||
408 | |||
409 | #else | ||
410 | |||
411 | MY_UNKNOWN_IMP | ||
412 | |||
413 | #endif // EXTERNAL_CODECS | ||
414 | |||
415 | |||
416 | #ifdef EXTERNAL_CODECS | ||
417 | 395 | ||
418 | int GetCodec_LibIndex(UInt32 index) const; | 396 | int GetCodec_LibIndex(UInt32 index) const; |
419 | bool GetCodec_DecoderIsAssigned(UInt32 index) const; | 397 | bool GetCodec_DecoderIsAssigned(UInt32 index) const; |
@@ -435,7 +413,7 @@ public: | |||
435 | HRESULT CreateInArchive(unsigned formatIndex, CMyComPtr<IInArchive> &archive) const | 413 | HRESULT CreateInArchive(unsigned formatIndex, CMyComPtr<IInArchive> &archive) const |
436 | { | 414 | { |
437 | const CArcInfoEx &ai = Formats[formatIndex]; | 415 | const CArcInfoEx &ai = Formats[formatIndex]; |
438 | #ifdef EXTERNAL_CODECS | 416 | #ifdef Z7_EXTERNAL_CODECS |
439 | if (ai.LibIndex < 0) | 417 | if (ai.LibIndex < 0) |
440 | #endif | 418 | #endif |
441 | { | 419 | { |
@@ -444,17 +422,17 @@ public: | |||
444 | return S_OK; | 422 | return S_OK; |
445 | COM_TRY_END | 423 | COM_TRY_END |
446 | } | 424 | } |
447 | #ifdef EXTERNAL_CODECS | 425 | #ifdef Z7_EXTERNAL_CODECS |
448 | return CreateArchiveHandler(ai, false, (void **)&archive); | 426 | return CreateArchiveHandler(ai, false, (void **)&archive); |
449 | #endif | 427 | #endif |
450 | } | 428 | } |
451 | 429 | ||
452 | #ifndef _SFX | 430 | #ifndef Z7_SFX |
453 | 431 | ||
454 | HRESULT CreateOutArchive(unsigned formatIndex, CMyComPtr<IOutArchive> &archive) const | 432 | HRESULT CreateOutArchive(unsigned formatIndex, CMyComPtr<IOutArchive> &archive) const |
455 | { | 433 | { |
456 | const CArcInfoEx &ai = Formats[formatIndex]; | 434 | const CArcInfoEx &ai = Formats[formatIndex]; |
457 | #ifdef EXTERNAL_CODECS | 435 | #ifdef Z7_EXTERNAL_CODECS |
458 | if (ai.LibIndex < 0) | 436 | if (ai.LibIndex < 0) |
459 | #endif | 437 | #endif |
460 | { | 438 | { |
@@ -464,7 +442,7 @@ public: | |||
464 | COM_TRY_END | 442 | COM_TRY_END |
465 | } | 443 | } |
466 | 444 | ||
467 | #ifdef EXTERNAL_CODECS | 445 | #ifdef Z7_EXTERNAL_CODECS |
468 | return CreateArchiveHandler(ai, true, (void **)&archive); | 446 | return CreateArchiveHandler(ai, true, (void **)&archive); |
469 | #endif | 447 | #endif |
470 | } | 448 | } |
@@ -484,21 +462,21 @@ public: | |||
484 | 462 | ||
485 | void Get_CodecsInfoUser_Vector(CObjectVector<CCodecInfoUser> &v); | 463 | void Get_CodecsInfoUser_Vector(CObjectVector<CCodecInfoUser> &v); |
486 | 464 | ||
487 | #endif // _SFX | 465 | #endif // Z7_SFX |
488 | }; | 466 | }; |
489 | 467 | ||
490 | #ifdef EXTERNAL_CODECS | 468 | #ifdef Z7_EXTERNAL_CODECS |
491 | #define CREATE_CODECS_OBJECT \ | 469 | #define CREATE_CODECS_OBJECT \ |
492 | CCodecs *codecs = new CCodecs; \ | 470 | CCodecs *codecs = new CCodecs; \ |
493 | CExternalCodecs __externalCodecs; \ | 471 | CExternalCodecs _externalCodecs; \ |
494 | __externalCodecs.GetCodecs = codecs; \ | 472 | _externalCodecs.GetCodecs = codecs; \ |
495 | __externalCodecs.GetHashers = codecs; \ | 473 | _externalCodecs.GetHashers = codecs; \ |
496 | CCodecs::CReleaser codecsReleaser; \ | 474 | CCodecs::CReleaser codecsReleaser; \ |
497 | codecsReleaser.Set(codecs); | 475 | codecsReleaser.Set(codecs); |
498 | #else | 476 | #else |
499 | #define CREATE_CODECS_OBJECT \ | 477 | #define CREATE_CODECS_OBJECT \ |
500 | CCodecs *codecs = new CCodecs; \ | 478 | CCodecs *codecs = new CCodecs; \ |
501 | CMyComPtr<IUnknown> __codecsRef = codecs; | 479 | CMyComPtr<IUnknown> _codecsRef = codecs; |
502 | #endif | 480 | #endif |
503 | 481 | ||
504 | #endif | 482 | #endif |
diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp index 4a91a26..a501b86 100644 --- a/CPP/7zip/UI/Common/OpenArchive.cpp +++ b/CPP/7zip/UI/Common/OpenArchive.cpp | |||
@@ -29,11 +29,11 @@ | |||
29 | #include "DefaultName.h" | 29 | #include "DefaultName.h" |
30 | #include "OpenArchive.h" | 30 | #include "OpenArchive.h" |
31 | 31 | ||
32 | #ifndef _SFX | 32 | #ifndef Z7_SFX |
33 | #include "SetProperties.h" | 33 | #include "SetProperties.h" |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #ifndef _SFX | 36 | #ifndef Z7_SFX |
37 | #ifdef SHOW_DEBUG_INFO | 37 | #ifdef SHOW_DEBUG_INFO |
38 | #define PRF(x) x | 38 | #define PRF(x) x |
39 | #else | 39 | #else |
@@ -95,7 +95,7 @@ Open: | |||
95 | using namespace NWindows; | 95 | using namespace NWindows; |
96 | 96 | ||
97 | /* | 97 | /* |
98 | #ifdef _SFX | 98 | #ifdef Z7_SFX |
99 | #define OPEN_PROPS_PARAM | 99 | #define OPEN_PROPS_PARAM |
100 | #else | 100 | #else |
101 | #define OPEN_PROPS_PARAM , props | 101 | #define OPEN_PROPS_PARAM , props |
@@ -111,7 +111,7 @@ CArc::~CArc() | |||
111 | } | 111 | } |
112 | */ | 112 | */ |
113 | 113 | ||
114 | #ifndef _SFX | 114 | #ifndef Z7_SFX |
115 | 115 | ||
116 | namespace NArchive { | 116 | namespace NArchive { |
117 | namespace NParser { | 117 | namespace NParser { |
@@ -172,23 +172,14 @@ struct CParseItem | |||
172 | } | 172 | } |
173 | }; | 173 | }; |
174 | 174 | ||
175 | class CHandler: | 175 | Z7_CLASS_IMP_CHandler_IInArchive_1( |
176 | public IInArchive, | 176 | IInArchiveGetStream |
177 | public IInArchiveGetStream, | 177 | ) |
178 | public CMyUnknownImp | ||
179 | { | ||
180 | public: | 178 | public: |
181 | CObjectVector<CParseItem> _items; | 179 | CObjectVector<CParseItem> _items; |
182 | UInt64 _maxEndOffset; | 180 | UInt64 _maxEndOffset; |
183 | CMyComPtr<IInStream> _stream; | 181 | CMyComPtr<IInStream> _stream; |
184 | 182 | ||
185 | MY_UNKNOWN_IMP2( | ||
186 | IInArchive, | ||
187 | IInArchiveGetStream) | ||
188 | |||
189 | INTERFACE_IInArchive(;) | ||
190 | STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream); | ||
191 | |||
192 | UInt64 GetLastEnd() const | 183 | UInt64 GetLastEnd() const |
193 | { | 184 | { |
194 | if (_items.IsEmpty()) | 185 | if (_items.IsEmpty()) |
@@ -300,7 +291,7 @@ static const Byte kProps[] = | |||
300 | IMP_IInArchive_Props | 291 | IMP_IInArchive_Props |
301 | IMP_IInArchive_ArcProps_NO | 292 | IMP_IInArchive_ArcProps_NO |
302 | 293 | ||
303 | STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback * /* openArchiveCallback */) | 294 | Z7_COM7F_IMF(CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback * /* openArchiveCallback */)) |
304 | { | 295 | { |
305 | COM_TRY_BEGIN | 296 | COM_TRY_BEGIN |
306 | { | 297 | { |
@@ -311,20 +302,20 @@ STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallb | |||
311 | COM_TRY_END | 302 | COM_TRY_END |
312 | } | 303 | } |
313 | 304 | ||
314 | STDMETHODIMP CHandler::Close() | 305 | Z7_COM7F_IMF(CHandler::Close()) |
315 | { | 306 | { |
316 | _items.Clear(); | 307 | _items.Clear(); |
317 | _stream.Release(); | 308 | _stream.Release(); |
318 | return S_OK; | 309 | return S_OK; |
319 | } | 310 | } |
320 | 311 | ||
321 | STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) | 312 | Z7_COM7F_IMF(CHandler::GetNumberOfItems(UInt32 *numItems)) |
322 | { | 313 | { |
323 | *numItems = _items.Size(); | 314 | *numItems = _items.Size(); |
324 | return S_OK; | 315 | return S_OK; |
325 | } | 316 | } |
326 | 317 | ||
327 | STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) | 318 | Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)) |
328 | { | 319 | { |
329 | COM_TRY_BEGIN | 320 | COM_TRY_BEGIN |
330 | NCOM::CPropVariant prop; | 321 | NCOM::CPropVariant prop; |
@@ -340,12 +331,12 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val | |||
340 | UString s(sz); | 331 | UString s(sz); |
341 | if (!item.Name.IsEmpty()) | 332 | if (!item.Name.IsEmpty()) |
342 | { | 333 | { |
343 | s += '.'; | 334 | s.Add_Dot(); |
344 | s += item.Name; | 335 | s += item.Name; |
345 | } | 336 | } |
346 | if (!item.Extension.IsEmpty()) | 337 | if (!item.Extension.IsEmpty()) |
347 | { | 338 | { |
348 | s += '.'; | 339 | s.Add_Dot(); |
349 | s += item.Extension; | 340 | s += item.Extension; |
350 | } | 341 | } |
351 | prop = s; break; | 342 | prop = s; break; |
@@ -365,12 +356,12 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val | |||
365 | COM_TRY_END | 356 | COM_TRY_END |
366 | } | 357 | } |
367 | 358 | ||
368 | HRESULT CHandler::Extract(const UInt32 *indices, UInt32 numItems, | 359 | Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems, |
369 | Int32 testMode, IArchiveExtractCallback *extractCallback) | 360 | Int32 testMode, IArchiveExtractCallback *extractCallback)) |
370 | { | 361 | { |
371 | COM_TRY_BEGIN | 362 | COM_TRY_BEGIN |
372 | 363 | ||
373 | bool allFilesMode = (numItems == (UInt32)(Int32)-1); | 364 | const bool allFilesMode = (numItems == (UInt32)(Int32)-1); |
374 | if (allFilesMode) | 365 | if (allFilesMode) |
375 | numItems = _items.Size(); | 366 | numItems = _items.Size(); |
376 | if (_stream && numItems == 0) | 367 | if (_stream && numItems == 0) |
@@ -401,35 +392,35 @@ HRESULT CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
401 | { | 392 | { |
402 | lps->InSize = totalSize; | 393 | lps->InSize = totalSize; |
403 | lps->OutSize = totalSize; | 394 | lps->OutSize = totalSize; |
404 | RINOK(lps->SetCur()); | 395 | RINOK(lps->SetCur()) |
405 | CMyComPtr<ISequentialOutStream> realOutStream; | 396 | CMyComPtr<ISequentialOutStream> realOutStream; |
406 | Int32 askMode = testMode ? | 397 | const Int32 askMode = testMode ? |
407 | NExtract::NAskMode::kTest : | 398 | NExtract::NAskMode::kTest : |
408 | NExtract::NAskMode::kExtract; | 399 | NExtract::NAskMode::kExtract; |
409 | UInt32 index = allFilesMode ? i : indices[i]; | 400 | const UInt32 index = allFilesMode ? i : indices[i]; |
410 | const CParseItem &item = _items[index]; | 401 | const CParseItem &item = _items[index]; |
411 | 402 | ||
412 | RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); | 403 | RINOK(extractCallback->GetStream(index, &realOutStream, askMode)) |
413 | UInt64 unpackSize = item.Size; | 404 | UInt64 unpackSize = item.Size; |
414 | totalSize += unpackSize; | 405 | totalSize += unpackSize; |
415 | bool skipMode = false; | 406 | bool skipMode = false; |
416 | if (!testMode && !realOutStream) | 407 | if (!testMode && !realOutStream) |
417 | continue; | 408 | continue; |
418 | RINOK(extractCallback->PrepareOperation(askMode)); | 409 | RINOK(extractCallback->PrepareOperation(askMode)) |
419 | 410 | ||
420 | outStreamSpec->SetStream(realOutStream); | 411 | outStreamSpec->SetStream(realOutStream); |
421 | realOutStream.Release(); | 412 | realOutStream.Release(); |
422 | outStreamSpec->Init(skipMode ? 0 : unpackSize, true); | 413 | outStreamSpec->Init(skipMode ? 0 : unpackSize, true); |
423 | 414 | ||
424 | Int32 opRes = NExtract::NOperationResult::kOK; | 415 | Int32 opRes = NExtract::NOperationResult::kOK; |
425 | RINOK(_stream->Seek((Int64)item.Offset, STREAM_SEEK_SET, NULL)); | 416 | RINOK(InStream_SeekSet(_stream, item.Offset)) |
426 | streamSpec->Init(unpackSize); | 417 | streamSpec->Init(unpackSize); |
427 | RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); | 418 | RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)) |
428 | 419 | ||
429 | if (outStreamSpec->GetRem() != 0) | 420 | if (outStreamSpec->GetRem() != 0) |
430 | opRes = NExtract::NOperationResult::kDataError; | 421 | opRes = NExtract::NOperationResult::kDataError; |
431 | outStreamSpec->ReleaseStream(); | 422 | outStreamSpec->ReleaseStream(); |
432 | RINOK(extractCallback->SetOperationResult(opRes)); | 423 | RINOK(extractCallback->SetOperationResult(opRes)) |
433 | } | 424 | } |
434 | 425 | ||
435 | return S_OK; | 426 | return S_OK; |
@@ -438,7 +429,7 @@ HRESULT CHandler::Extract(const UInt32 *indices, UInt32 numItems, | |||
438 | } | 429 | } |
439 | 430 | ||
440 | 431 | ||
441 | STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) | 432 | Z7_COM7F_IMF(CHandler::GetStream(UInt32 index, ISequentialInStream **stream)) |
442 | { | 433 | { |
443 | COM_TRY_BEGIN | 434 | COM_TRY_BEGIN |
444 | const CParseItem &item = _items[index]; | 435 | const CParseItem &item = _items[index]; |
@@ -454,7 +445,7 @@ HRESULT Archive_GetItemBoolProp(IInArchive *arc, UInt32 index, PROPID propID, bo | |||
454 | { | 445 | { |
455 | NCOM::CPropVariant prop; | 446 | NCOM::CPropVariant prop; |
456 | result = false; | 447 | result = false; |
457 | RINOK(arc->GetProperty(index, propID, &prop)); | 448 | RINOK(arc->GetProperty(index, propID, &prop)) |
458 | if (prop.vt == VT_BOOL) | 449 | if (prop.vt == VT_BOOL) |
459 | result = VARIANT_BOOLToBool(prop.boolVal); | 450 | result = VARIANT_BOOLToBool(prop.boolVal); |
460 | else if (prop.vt != VT_EMPTY) | 451 | else if (prop.vt != VT_EMPTY) |
@@ -486,7 +477,7 @@ static HRESULT Archive_GetArcProp_Bool(IInArchive *arc, PROPID propid, bool &res | |||
486 | { | 477 | { |
487 | NCOM::CPropVariant prop; | 478 | NCOM::CPropVariant prop; |
488 | result = false; | 479 | result = false; |
489 | RINOK(arc->GetArchiveProperty(propid, &prop)); | 480 | RINOK(arc->GetArchiveProperty(propid, &prop)) |
490 | if (prop.vt == VT_BOOL) | 481 | if (prop.vt == VT_BOOL) |
491 | result = VARIANT_BOOLToBool(prop.boolVal); | 482 | result = VARIANT_BOOLToBool(prop.boolVal); |
492 | else if (prop.vt != VT_EMPTY) | 483 | else if (prop.vt != VT_EMPTY) |
@@ -498,7 +489,7 @@ static HRESULT Archive_GetArcProp_UInt(IInArchive *arc, PROPID propid, UInt64 &r | |||
498 | { | 489 | { |
499 | defined = false; | 490 | defined = false; |
500 | NCOM::CPropVariant prop; | 491 | NCOM::CPropVariant prop; |
501 | RINOK(arc->GetArchiveProperty(propid, &prop)); | 492 | RINOK(arc->GetArchiveProperty(propid, &prop)) |
502 | switch (prop.vt) | 493 | switch (prop.vt) |
503 | { | 494 | { |
504 | case VT_UI4: result = prop.ulVal; break; | 495 | case VT_UI4: result = prop.ulVal; break; |
@@ -516,7 +507,7 @@ static HRESULT Archive_GetArcProp_Int(IInArchive *arc, PROPID propid, Int64 &res | |||
516 | { | 507 | { |
517 | defined = false; | 508 | defined = false; |
518 | NCOM::CPropVariant prop; | 509 | NCOM::CPropVariant prop; |
519 | RINOK(arc->GetArchiveProperty(propid, &prop)); | 510 | RINOK(arc->GetArchiveProperty(propid, &prop)) |
520 | switch (prop.vt) | 511 | switch (prop.vt) |
521 | { | 512 | { |
522 | case VT_UI4: result = prop.ulVal; break; | 513 | case VT_UI4: result = prop.ulVal; break; |
@@ -530,7 +521,7 @@ static HRESULT Archive_GetArcProp_Int(IInArchive *arc, PROPID propid, Int64 &res | |||
530 | return S_OK; | 521 | return S_OK; |
531 | } | 522 | } |
532 | 523 | ||
533 | #ifndef _SFX | 524 | #ifndef Z7_SFX |
534 | 525 | ||
535 | HRESULT CArc::GetItem_PathToParent(UInt32 index, UInt32 parent, UStringVector &parts) const | 526 | HRESULT CArc::GetItem_PathToParent(UInt32 index, UInt32 parent, UStringVector &parts) const |
536 | { | 527 | { |
@@ -550,14 +541,14 @@ HRESULT CArc::GetItem_PathToParent(UInt32 index, UInt32 parent, UStringVector &p | |||
550 | const void *p; | 541 | const void *p; |
551 | UInt32 size; | 542 | UInt32 size; |
552 | UInt32 propType; | 543 | UInt32 propType; |
553 | RINOK(GetRawProps->GetRawProp(curIndex, kpidName, &p, &size, &propType)); | 544 | RINOK(GetRawProps->GetRawProp(curIndex, kpidName, &p, &size, &propType)) |
554 | if (p && propType == PROP_DATA_TYPE_wchar_t_PTR_Z_LE) | 545 | if (p && propType == PROP_DATA_TYPE_wchar_t_PTR_Z_LE) |
555 | s = (const wchar_t *)p; | 546 | s = (const wchar_t *)p; |
556 | else | 547 | else |
557 | #endif | 548 | #endif |
558 | { | 549 | { |
559 | NCOM::CPropVariant prop; | 550 | NCOM::CPropVariant prop; |
560 | RINOK(Archive->GetProperty(curIndex, kpidName, &prop)); | 551 | RINOK(Archive->GetProperty(curIndex, kpidName, &prop)) |
561 | if (prop.vt == VT_BSTR && prop.bstrVal) | 552 | if (prop.vt == VT_BSTR && prop.bstrVal) |
562 | s.SetFromBstr(prop.bstrVal); | 553 | s.SetFromBstr(prop.bstrVal); |
563 | else if (prop.vt == VT_EMPTY) | 554 | else if (prop.vt == VT_EMPTY) |
@@ -568,7 +559,7 @@ HRESULT CArc::GetItem_PathToParent(UInt32 index, UInt32 parent, UStringVector &p | |||
568 | 559 | ||
569 | UInt32 curParent = (UInt32)(Int32)-1; | 560 | UInt32 curParent = (UInt32)(Int32)-1; |
570 | UInt32 parentType = 0; | 561 | UInt32 parentType = 0; |
571 | RINOK(GetRawProps->GetParent(curIndex, &curParent, &parentType)); | 562 | RINOK(GetRawProps->GetParent(curIndex, &curParent, &parentType)) |
572 | 563 | ||
573 | // 18.06: fixed : we don't want to split name to parts | 564 | // 18.06: fixed : we don't want to split name to parts |
574 | /* | 565 | /* |
@@ -742,7 +733,7 @@ HRESULT CArc::GetItem_Path(UInt32 index, UString &result) const | |||
742 | 733 | ||
743 | { | 734 | { |
744 | NCOM::CPropVariant prop; | 735 | NCOM::CPropVariant prop; |
745 | RINOK(Archive->GetProperty(index, kpidPath, &prop)); | 736 | RINOK(Archive->GetProperty(index, kpidPath, &prop)) |
746 | if (prop.vt == VT_BSTR && prop.bstrVal) | 737 | if (prop.vt == VT_BSTR && prop.bstrVal) |
747 | result.SetFromBstr(prop.bstrVal); | 738 | result.SetFromBstr(prop.bstrVal); |
748 | else if (prop.vt == VT_EMPTY) | 739 | else if (prop.vt == VT_EMPTY) |
@@ -762,15 +753,15 @@ HRESULT CArc::GetItem_DefaultPath(UInt32 index, UString &result) const | |||
762 | { | 753 | { |
763 | result.Empty(); | 754 | result.Empty(); |
764 | bool isDir; | 755 | bool isDir; |
765 | RINOK(Archive_IsItem_Dir(Archive, index, isDir)); | 756 | RINOK(Archive_IsItem_Dir(Archive, index, isDir)) |
766 | if (!isDir) | 757 | if (!isDir) |
767 | { | 758 | { |
768 | result = DefaultName; | 759 | result = DefaultName; |
769 | NCOM::CPropVariant prop; | 760 | NCOM::CPropVariant prop; |
770 | RINOK(Archive->GetProperty(index, kpidExtension, &prop)); | 761 | RINOK(Archive->GetProperty(index, kpidExtension, &prop)) |
771 | if (prop.vt == VT_BSTR) | 762 | if (prop.vt == VT_BSTR) |
772 | { | 763 | { |
773 | result += '.'; | 764 | result.Add_Dot(); |
774 | result += prop.bstrVal; | 765 | result += prop.bstrVal; |
775 | } | 766 | } |
776 | else if (prop.vt != VT_EMPTY) | 767 | else if (prop.vt != VT_EMPTY) |
@@ -781,11 +772,11 @@ HRESULT CArc::GetItem_DefaultPath(UInt32 index, UString &result) const | |||
781 | 772 | ||
782 | HRESULT CArc::GetItem_Path2(UInt32 index, UString &result) const | 773 | HRESULT CArc::GetItem_Path2(UInt32 index, UString &result) const |
783 | { | 774 | { |
784 | RINOK(GetItem_Path(index, result)); | 775 | RINOK(GetItem_Path(index, result)) |
785 | if (Ask_Deleted) | 776 | if (Ask_Deleted) |
786 | { | 777 | { |
787 | bool isDeleted = false; | 778 | bool isDeleted = false; |
788 | RINOK(Archive_IsItem_Deleted(Archive, index, isDeleted)); | 779 | RINOK(Archive_IsItem_Deleted(Archive, index, isDeleted)) |
789 | if (isDeleted) | 780 | if (isDeleted) |
790 | result.Insert(0, L"[DELETED]" WSTRING_PATH_SEPARATOR); | 781 | result.Insert(0, L"[DELETED]" WSTRING_PATH_SEPARATOR); |
791 | } | 782 | } |
@@ -830,12 +821,12 @@ HRESULT CArc::GetItem(UInt32 index, CReadArcItem &item) const | |||
830 | 821 | ||
831 | item.PathParts.Clear(); | 822 | item.PathParts.Clear(); |
832 | 823 | ||
833 | RINOK(Archive_IsItem_Dir(Archive, index, item.IsDir)); | 824 | RINOK(Archive_IsItem_Dir(Archive, index, item.IsDir)) |
834 | item.MainIsDir = item.IsDir; | 825 | item.MainIsDir = item.IsDir; |
835 | 826 | ||
836 | RINOK(GetItem_Path2(index, item.Path)); | 827 | RINOK(GetItem_Path2(index, item.Path)) |
837 | 828 | ||
838 | #ifndef _SFX | 829 | #ifndef Z7_SFX |
839 | UInt32 mainIndex = index; | 830 | UInt32 mainIndex = index; |
840 | #endif | 831 | #endif |
841 | 832 | ||
@@ -844,7 +835,7 @@ HRESULT CArc::GetItem(UInt32 index, CReadArcItem &item) const | |||
844 | item.MainPath = item.Path; | 835 | item.MainPath = item.Path; |
845 | if (Ask_AltStream) | 836 | if (Ask_AltStream) |
846 | { | 837 | { |
847 | RINOK(Archive_IsItem_AltStream(Archive, index, item.IsAltStream)); | 838 | RINOK(Archive_IsItem_AltStream(Archive, index, item.IsAltStream)) |
848 | } | 839 | } |
849 | 840 | ||
850 | bool needFindAltStream = false; | 841 | bool needFindAltStream = false; |
@@ -856,11 +847,11 @@ HRESULT CArc::GetItem(UInt32 index, CReadArcItem &item) const | |||
856 | { | 847 | { |
857 | UInt32 parentType = 0; | 848 | UInt32 parentType = 0; |
858 | UInt32 parentIndex; | 849 | UInt32 parentIndex; |
859 | RINOK(GetRawProps->GetParent(index, &parentIndex, &parentType)); | 850 | RINOK(GetRawProps->GetParent(index, &parentIndex, &parentType)) |
860 | if (parentType == NParentType::kAltStream) | 851 | if (parentType == NParentType::kAltStream) |
861 | { | 852 | { |
862 | NCOM::CPropVariant prop; | 853 | NCOM::CPropVariant prop; |
863 | RINOK(Archive->GetProperty(index, kpidName, &prop)); | 854 | RINOK(Archive->GetProperty(index, kpidName, &prop)) |
864 | if (prop.vt == VT_BSTR && prop.bstrVal) | 855 | if (prop.vt == VT_BSTR && prop.bstrVal) |
865 | item.AltStreamName.SetFromBstr(prop.bstrVal); | 856 | item.AltStreamName.SetFromBstr(prop.bstrVal); |
866 | else if (prop.vt != VT_EMPTY) | 857 | else if (prop.vt != VT_EMPTY) |
@@ -885,8 +876,8 @@ HRESULT CArc::GetItem(UInt32 index, CReadArcItem &item) const | |||
885 | } | 876 | } |
886 | else | 877 | else |
887 | { | 878 | { |
888 | RINOK(GetItem_Path2(parentIndex, item.MainPath)); | 879 | RINOK(GetItem_Path2(parentIndex, item.MainPath)) |
889 | RINOK(Archive_IsItem_Dir(Archive, parentIndex, item.MainIsDir)); | 880 | RINOK(Archive_IsItem_Dir(Archive, parentIndex, item.MainIsDir)) |
890 | } | 881 | } |
891 | } | 882 | } |
892 | } | 883 | } |
@@ -908,10 +899,10 @@ HRESULT CArc::GetItem(UInt32 index, CReadArcItem &item) const | |||
908 | 899 | ||
909 | #endif | 900 | #endif |
910 | 901 | ||
911 | #ifndef _SFX | 902 | #ifndef Z7_SFX |
912 | if (item._use_baseParentFolder_mode) | 903 | if (item._use_baseParentFolder_mode) |
913 | { | 904 | { |
914 | RINOK(GetItem_PathToParent(mainIndex, (unsigned)item._baseParentFolder, item.PathParts)); | 905 | RINOK(GetItem_PathToParent(mainIndex, (unsigned)item._baseParentFolder, item.PathParts)) |
915 | 906 | ||
916 | #ifdef SUPPORT_ALT_STREAMS | 907 | #ifdef SUPPORT_ALT_STREAMS |
917 | if ((item.WriteToAltStreamIfColon || needFindAltStream) && !item.PathParts.IsEmpty()) | 908 | if ((item.WriteToAltStreamIfColon || needFindAltStream) && !item.PathParts.IsEmpty()) |
@@ -947,14 +938,14 @@ HRESULT CArc::GetItem(UInt32 index, CReadArcItem &item) const | |||
947 | return S_OK; | 938 | return S_OK; |
948 | } | 939 | } |
949 | 940 | ||
950 | #ifndef _SFX | 941 | #ifndef Z7_SFX |
951 | 942 | ||
952 | static HRESULT Archive_GetItem_Size(IInArchive *archive, UInt32 index, UInt64 &size, bool &defined) | 943 | static HRESULT Archive_GetItem_Size(IInArchive *archive, UInt32 index, UInt64 &size, bool &defined) |
953 | { | 944 | { |
954 | NCOM::CPropVariant prop; | 945 | NCOM::CPropVariant prop; |
955 | defined = false; | 946 | defined = false; |
956 | size = 0; | 947 | size = 0; |
957 | RINOK(archive->GetProperty(index, kpidSize, &prop)); | 948 | RINOK(archive->GetProperty(index, kpidSize, &prop)) |
958 | switch (prop.vt) | 949 | switch (prop.vt) |
959 | { | 950 | { |
960 | case VT_UI1: size = prop.bVal; break; | 951 | case VT_UI1: size = prop.bVal; break; |
@@ -975,7 +966,7 @@ HRESULT CArc::GetItem_Size(UInt32 index, UInt64 &size, bool &defined) const | |||
975 | NCOM::CPropVariant prop; | 966 | NCOM::CPropVariant prop; |
976 | defined = false; | 967 | defined = false; |
977 | size = 0; | 968 | size = 0; |
978 | RINOK(Archive->GetProperty(index, kpidSize, &prop)); | 969 | RINOK(Archive->GetProperty(index, kpidSize, &prop)) |
979 | switch (prop.vt) | 970 | switch (prop.vt) |
980 | { | 971 | { |
981 | case VT_UI1: size = prop.bVal; break; | 972 | case VT_UI1: size = prop.bVal; break; |
@@ -993,7 +984,7 @@ HRESULT CArc::GetItem_MTime(UInt32 index, CArcTime &at) const | |||
993 | { | 984 | { |
994 | at.Clear(); | 985 | at.Clear(); |
995 | NCOM::CPropVariant prop; | 986 | NCOM::CPropVariant prop; |
996 | RINOK(Archive->GetProperty(index, kpidMTime, &prop)); | 987 | RINOK(Archive->GetProperty(index, kpidMTime, &prop)) |
997 | 988 | ||
998 | if (prop.vt == VT_FILETIME) | 989 | if (prop.vt == VT_FILETIME) |
999 | { | 990 | { |
@@ -1011,7 +1002,7 @@ HRESULT CArc::GetItem_MTime(UInt32 index, CArcTime &at) const | |||
1011 | // (at.Prec == 0) before version 22. | 1002 | // (at.Prec == 0) before version 22. |
1012 | // so kpidTimeType is required for that code | 1003 | // so kpidTimeType is required for that code |
1013 | prop.Clear(); | 1004 | prop.Clear(); |
1014 | RINOK(Archive->GetProperty(index, kpidTimeType, &prop)); | 1005 | RINOK(Archive->GetProperty(index, kpidTimeType, &prop)) |
1015 | if (prop.vt == VT_UI4) | 1006 | if (prop.vt == VT_UI4) |
1016 | { | 1007 | { |
1017 | UInt32 val = prop.ulVal; | 1008 | UInt32 val = prop.ulVal; |
@@ -1038,7 +1029,7 @@ HRESULT CArc::GetItem_MTime(UInt32 index, CArcTime &at) const | |||
1038 | return S_OK; | 1029 | return S_OK; |
1039 | } | 1030 | } |
1040 | 1031 | ||
1041 | #ifndef _SFX | 1032 | #ifndef Z7_SFX |
1042 | 1033 | ||
1043 | static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size) | 1034 | static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size) |
1044 | { | 1035 | { |
@@ -1121,7 +1112,7 @@ static bool IsPreArcFormat(const CArcInfoEx &ai) | |||
1121 | { | 1112 | { |
1122 | if (ai.Flags_PreArc()) | 1113 | if (ai.Flags_PreArc()) |
1123 | return true; | 1114 | return true; |
1124 | return IsNameFromList(ai.Name, k_PreArcFormats, ARRAY_SIZE(k_PreArcFormats)); | 1115 | return IsNameFromList(ai.Name, k_PreArcFormats, Z7_ARRAY_SIZE(k_PreArcFormats)); |
1125 | } | 1116 | } |
1126 | 1117 | ||
1127 | static const char * const k_Formats_with_simple_signuature[] = | 1118 | static const char * const k_Formats_with_simple_signuature[] = |
@@ -1143,44 +1134,46 @@ static bool IsNewStyleSignature(const CArcInfoEx &ai) | |||
1143 | // if (ai.Version >= 0x91F) | 1134 | // if (ai.Version >= 0x91F) |
1144 | if (ai.NewInterface) | 1135 | if (ai.NewInterface) |
1145 | return true; | 1136 | return true; |
1146 | return IsNameFromList(ai.Name, k_Formats_with_simple_signuature, ARRAY_SIZE(k_Formats_with_simple_signuature)); | 1137 | return IsNameFromList(ai.Name, k_Formats_with_simple_signuature, Z7_ARRAY_SIZE(k_Formats_with_simple_signuature)); |
1147 | } | 1138 | } |
1148 | 1139 | ||
1149 | class CArchiveOpenCallback_Offset: | 1140 | |
1141 | |||
1142 | class CArchiveOpenCallback_Offset Z7_final: | ||
1150 | public IArchiveOpenCallback, | 1143 | public IArchiveOpenCallback, |
1151 | public IArchiveOpenVolumeCallback, | 1144 | public IArchiveOpenVolumeCallback, |
1152 | #ifndef _NO_CRYPTO | 1145 | #ifndef Z7_NO_CRYPTO |
1153 | public ICryptoGetTextPassword, | 1146 | public ICryptoGetTextPassword, |
1154 | #endif | 1147 | #endif |
1155 | public CMyUnknownImp | 1148 | public CMyUnknownImp |
1156 | { | 1149 | { |
1150 | Z7_COM_QI_BEGIN2(IArchiveOpenCallback) | ||
1151 | Z7_COM_QI_ENTRY(IArchiveOpenVolumeCallback) | ||
1152 | #ifndef Z7_NO_CRYPTO | ||
1153 | Z7_COM_QI_ENTRY(ICryptoGetTextPassword) | ||
1154 | #endif | ||
1155 | Z7_COM_QI_END | ||
1156 | Z7_COM_ADDREF_RELEASE | ||
1157 | |||
1158 | Z7_IFACE_COM7_IMP(IArchiveOpenCallback) | ||
1159 | Z7_IFACE_COM7_IMP(IArchiveOpenVolumeCallback) | ||
1160 | #ifndef Z7_NO_CRYPTO | ||
1161 | Z7_IFACE_COM7_IMP(ICryptoGetTextPassword) | ||
1162 | #endif | ||
1163 | |||
1157 | public: | 1164 | public: |
1158 | CMyComPtr<IArchiveOpenCallback> Callback; | 1165 | CMyComPtr<IArchiveOpenCallback> Callback; |
1159 | CMyComPtr<IArchiveOpenVolumeCallback> OpenVolumeCallback; | 1166 | CMyComPtr<IArchiveOpenVolumeCallback> OpenVolumeCallback; |
1160 | UInt64 Files; | 1167 | UInt64 Files; |
1161 | UInt64 Offset; | 1168 | UInt64 Offset; |
1162 | 1169 | ||
1163 | #ifndef _NO_CRYPTO | 1170 | #ifndef Z7_NO_CRYPTO |
1164 | CMyComPtr<ICryptoGetTextPassword> GetTextPassword; | 1171 | CMyComPtr<ICryptoGetTextPassword> GetTextPassword; |
1165 | #endif | 1172 | #endif |
1166 | |||
1167 | MY_QUERYINTERFACE_BEGIN2(IArchiveOpenCallback) | ||
1168 | MY_QUERYINTERFACE_ENTRY(IArchiveOpenVolumeCallback) | ||
1169 | #ifndef _NO_CRYPTO | ||
1170 | MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword) | ||
1171 | #endif | ||
1172 | MY_QUERYINTERFACE_END | ||
1173 | MY_ADDREF_RELEASE | ||
1174 | |||
1175 | INTERFACE_IArchiveOpenCallback(;) | ||
1176 | INTERFACE_IArchiveOpenVolumeCallback(;) | ||
1177 | #ifndef _NO_CRYPTO | ||
1178 | STDMETHOD(CryptoGetTextPassword)(BSTR *password); | ||
1179 | #endif | ||
1180 | }; | 1173 | }; |
1181 | 1174 | ||
1182 | #ifndef _NO_CRYPTO | 1175 | #ifndef Z7_NO_CRYPTO |
1183 | STDMETHODIMP CArchiveOpenCallback_Offset::CryptoGetTextPassword(BSTR *password) | 1176 | Z7_COM7F_IMF(CArchiveOpenCallback_Offset::CryptoGetTextPassword(BSTR *password)) |
1184 | { | 1177 | { |
1185 | COM_TRY_BEGIN | 1178 | COM_TRY_BEGIN |
1186 | if (GetTextPassword) | 1179 | if (GetTextPassword) |
@@ -1190,12 +1183,12 @@ STDMETHODIMP CArchiveOpenCallback_Offset::CryptoGetTextPassword(BSTR *password) | |||
1190 | } | 1183 | } |
1191 | #endif | 1184 | #endif |
1192 | 1185 | ||
1193 | STDMETHODIMP CArchiveOpenCallback_Offset::SetTotal(const UInt64 *, const UInt64 *) | 1186 | Z7_COM7F_IMF(CArchiveOpenCallback_Offset::SetTotal(const UInt64 *, const UInt64 *)) |
1194 | { | 1187 | { |
1195 | return S_OK; | 1188 | return S_OK; |
1196 | } | 1189 | } |
1197 | 1190 | ||
1198 | STDMETHODIMP CArchiveOpenCallback_Offset::SetCompleted(const UInt64 *, const UInt64 *bytes) | 1191 | Z7_COM7F_IMF(CArchiveOpenCallback_Offset::SetCompleted(const UInt64 *, const UInt64 *bytes)) |
1199 | { | 1192 | { |
1200 | if (!Callback) | 1193 | if (!Callback) |
1201 | return S_OK; | 1194 | return S_OK; |
@@ -1205,7 +1198,7 @@ STDMETHODIMP CArchiveOpenCallback_Offset::SetCompleted(const UInt64 *, const UIn | |||
1205 | return Callback->SetCompleted(&Files, &value); | 1198 | return Callback->SetCompleted(&Files, &value); |
1206 | } | 1199 | } |
1207 | 1200 | ||
1208 | STDMETHODIMP CArchiveOpenCallback_Offset::GetProperty(PROPID propID, PROPVARIANT *value) | 1201 | Z7_COM7F_IMF(CArchiveOpenCallback_Offset::GetProperty(PROPID propID, PROPVARIANT *value)) |
1209 | { | 1202 | { |
1210 | if (OpenVolumeCallback) | 1203 | if (OpenVolumeCallback) |
1211 | return OpenVolumeCallback->GetProperty(propID, value); | 1204 | return OpenVolumeCallback->GetProperty(propID, value); |
@@ -1214,7 +1207,7 @@ STDMETHODIMP CArchiveOpenCallback_Offset::GetProperty(PROPID propID, PROPVARIANT | |||
1214 | // return E_NOTIMPL; | 1207 | // return E_NOTIMPL; |
1215 | } | 1208 | } |
1216 | 1209 | ||
1217 | STDMETHODIMP CArchiveOpenCallback_Offset::GetStream(const wchar_t *name, IInStream **inStream) | 1210 | Z7_COM7F_IMF(CArchiveOpenCallback_Offset::GetStream(const wchar_t *name, IInStream **inStream)) |
1218 | { | 1211 | { |
1219 | if (OpenVolumeCallback) | 1212 | if (OpenVolumeCallback) |
1220 | return OpenVolumeCallback->GetStream(name, inStream); | 1213 | return OpenVolumeCallback->GetStream(name, inStream); |
@@ -1266,32 +1259,32 @@ HRESULT CArc::ReadBasicProps(IInArchive *archive, UInt64 startPos, HRESULT openR | |||
1266 | ErrorInfo.ClearErrors(); | 1259 | ErrorInfo.ClearErrors(); |
1267 | { | 1260 | { |
1268 | NCOM::CPropVariant prop; | 1261 | NCOM::CPropVariant prop; |
1269 | RINOK(archive->GetArchiveProperty(kpidErrorFlags, &prop)); | 1262 | RINOK(archive->GetArchiveProperty(kpidErrorFlags, &prop)) |
1270 | ErrorInfo.ErrorFlags = GetOpenArcErrorFlags(prop, &ErrorInfo.ErrorFlags_Defined); | 1263 | ErrorInfo.ErrorFlags = GetOpenArcErrorFlags(prop, &ErrorInfo.ErrorFlags_Defined); |
1271 | } | 1264 | } |
1272 | { | 1265 | { |
1273 | NCOM::CPropVariant prop; | 1266 | NCOM::CPropVariant prop; |
1274 | RINOK(archive->GetArchiveProperty(kpidWarningFlags, &prop)); | 1267 | RINOK(archive->GetArchiveProperty(kpidWarningFlags, &prop)) |
1275 | ErrorInfo.WarningFlags = GetOpenArcErrorFlags(prop); | 1268 | ErrorInfo.WarningFlags = GetOpenArcErrorFlags(prop); |
1276 | } | 1269 | } |
1277 | 1270 | ||
1278 | { | 1271 | { |
1279 | NCOM::CPropVariant prop; | 1272 | NCOM::CPropVariant prop; |
1280 | RINOK(archive->GetArchiveProperty(kpidError, &prop)); | 1273 | RINOK(archive->GetArchiveProperty(kpidError, &prop)) |
1281 | if (prop.vt != VT_EMPTY) | 1274 | if (prop.vt != VT_EMPTY) |
1282 | ErrorInfo.ErrorMessage = (prop.vt == VT_BSTR ? prop.bstrVal : L"Unknown error"); | 1275 | ErrorInfo.ErrorMessage = (prop.vt == VT_BSTR ? prop.bstrVal : L"Unknown error"); |
1283 | } | 1276 | } |
1284 | 1277 | ||
1285 | { | 1278 | { |
1286 | NCOM::CPropVariant prop; | 1279 | NCOM::CPropVariant prop; |
1287 | RINOK(archive->GetArchiveProperty(kpidWarning, &prop)); | 1280 | RINOK(archive->GetArchiveProperty(kpidWarning, &prop)) |
1288 | if (prop.vt != VT_EMPTY) | 1281 | if (prop.vt != VT_EMPTY) |
1289 | ErrorInfo.WarningMessage = (prop.vt == VT_BSTR ? prop.bstrVal : L"Unknown warning"); | 1282 | ErrorInfo.WarningMessage = (prop.vt == VT_BSTR ? prop.bstrVal : L"Unknown warning"); |
1290 | } | 1283 | } |
1291 | 1284 | ||
1292 | if (openRes == S_OK || ErrorInfo.IsArc_After_NonOpen()) | 1285 | if (openRes == S_OK || ErrorInfo.IsArc_After_NonOpen()) |
1293 | { | 1286 | { |
1294 | RINOK(Archive_GetArcProp_UInt(archive, kpidPhySize, PhySize, PhySize_Defined)); | 1287 | RINOK(Archive_GetArcProp_UInt(archive, kpidPhySize, PhySize, PhySize_Defined)) |
1295 | /* | 1288 | /* |
1296 | RINOK(Archive_GetArcProp_UInt(archive, kpidOkPhySize, OkPhySize, OkPhySize_Defined)); | 1289 | RINOK(Archive_GetArcProp_UInt(archive, kpidOkPhySize, OkPhySize, OkPhySize_Defined)); |
1297 | if (!OkPhySize_Defined) | 1290 | if (!OkPhySize_Defined) |
@@ -1302,7 +1295,7 @@ HRESULT CArc::ReadBasicProps(IInArchive *archive, UInt64 startPos, HRESULT openR | |||
1302 | */ | 1295 | */ |
1303 | 1296 | ||
1304 | bool offsetDefined; | 1297 | bool offsetDefined; |
1305 | RINOK(Archive_GetArcProp_Int(archive, kpidOffset, Offset, offsetDefined)); | 1298 | RINOK(Archive_GetArcProp_Int(archive, kpidOffset, Offset, offsetDefined)) |
1306 | 1299 | ||
1307 | Int64 globalOffset = (Int64)startPos + Offset; | 1300 | Int64 globalOffset = (Int64)startPos + Offset; |
1308 | AvailPhySize = (UInt64)((Int64)FileSize - globalOffset); | 1301 | AvailPhySize = (UInt64)((Int64)FileSize - globalOffset); |
@@ -1338,12 +1331,12 @@ HRESULT CArc::PrepareToOpen(const COpenOptions &op, unsigned formatIndex, CMyCom | |||
1338 | // OutputDebugStringA("a1"); | 1331 | // OutputDebugStringA("a1"); |
1339 | // PrintNumber("formatIndex", formatIndex); | 1332 | // PrintNumber("formatIndex", formatIndex); |
1340 | 1333 | ||
1341 | RINOK(op.codecs->CreateInArchive(formatIndex, archive)); | 1334 | RINOK(op.codecs->CreateInArchive(formatIndex, archive)) |
1342 | // OutputDebugStringA("a2"); | 1335 | // OutputDebugStringA("a2"); |
1343 | if (!archive) | 1336 | if (!archive) |
1344 | return S_OK; | 1337 | return S_OK; |
1345 | 1338 | ||
1346 | #ifdef EXTERNAL_CODECS | 1339 | #ifdef Z7_EXTERNAL_CODECS |
1347 | if (op.codecs->NeedSetLibCodecs) | 1340 | if (op.codecs->NeedSetLibCodecs) |
1348 | { | 1341 | { |
1349 | const CArcInfoEx &ai = op.codecs->Formats[formatIndex]; | 1342 | const CArcInfoEx &ai = op.codecs->Formats[formatIndex]; |
@@ -1355,14 +1348,14 @@ HRESULT CArc::PrepareToOpen(const COpenOptions &op, unsigned formatIndex, CMyCom | |||
1355 | archive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo); | 1348 | archive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo); |
1356 | if (setCompressCodecsInfo) | 1349 | if (setCompressCodecsInfo) |
1357 | { | 1350 | { |
1358 | RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(op.codecs)); | 1351 | RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(op.codecs)) |
1359 | } | 1352 | } |
1360 | } | 1353 | } |
1361 | } | 1354 | } |
1362 | #endif | 1355 | #endif |
1363 | 1356 | ||
1364 | 1357 | ||
1365 | #ifndef _SFX | 1358 | #ifndef Z7_SFX |
1366 | 1359 | ||
1367 | const CArcInfoEx &ai = op.codecs->Formats[formatIndex]; | 1360 | const CArcInfoEx &ai = op.codecs->Formats[formatIndex]; |
1368 | 1361 | ||
@@ -1392,14 +1385,14 @@ HRESULT CArc::PrepareToOpen(const COpenOptions &op, unsigned formatIndex, CMyCom | |||
1392 | } | 1385 | } |
1393 | } | 1386 | } |
1394 | */ | 1387 | */ |
1395 | RINOK(SetProperties(archive, *op.props)); | 1388 | RINOK(SetProperties(archive, *op.props)) |
1396 | } | 1389 | } |
1397 | 1390 | ||
1398 | #endif | 1391 | #endif |
1399 | return S_OK; | 1392 | return S_OK; |
1400 | } | 1393 | } |
1401 | 1394 | ||
1402 | #ifndef _SFX | 1395 | #ifndef Z7_SFX |
1403 | 1396 | ||
1404 | static HRESULT ReadParseItemProps(IInArchive *archive, const CArcInfoEx &ai, NArchive::NParser::CParseItem &pi) | 1397 | static HRESULT ReadParseItemProps(IInArchive *archive, const CArcInfoEx &ai, NArchive::NParser::CParseItem &pi) |
1405 | { | 1398 | { |
@@ -1407,14 +1400,14 @@ static HRESULT ReadParseItemProps(IInArchive *archive, const CArcInfoEx &ai, NAr | |||
1407 | pi.FileTime_Defined = false; | 1400 | pi.FileTime_Defined = false; |
1408 | pi.ArcType = ai.Name; | 1401 | pi.ArcType = ai.Name; |
1409 | 1402 | ||
1410 | RINOK(Archive_GetArcProp_Bool(archive, kpidIsNotArcType, pi.IsNotArcType)); | 1403 | RINOK(Archive_GetArcProp_Bool(archive, kpidIsNotArcType, pi.IsNotArcType)) |
1411 | 1404 | ||
1412 | // RINOK(Archive_GetArcProp_Bool(archive, kpidIsSelfExe, pi.IsSelfExe)); | 1405 | // RINOK(Archive_GetArcProp_Bool(archive, kpidIsSelfExe, pi.IsSelfExe)); |
1413 | pi.IsSelfExe = ai.Flags_PreArc(); | 1406 | pi.IsSelfExe = ai.Flags_PreArc(); |
1414 | 1407 | ||
1415 | { | 1408 | { |
1416 | NCOM::CPropVariant prop; | 1409 | NCOM::CPropVariant prop; |
1417 | RINOK(archive->GetArchiveProperty(kpidMTime, &prop)); | 1410 | RINOK(archive->GetArchiveProperty(kpidMTime, &prop)) |
1418 | if (prop.vt == VT_FILETIME) | 1411 | if (prop.vt == VT_FILETIME) |
1419 | { | 1412 | { |
1420 | pi.FileTime_Defined = true; | 1413 | pi.FileTime_Defined = true; |
@@ -1425,7 +1418,7 @@ static HRESULT ReadParseItemProps(IInArchive *archive, const CArcInfoEx &ai, NAr | |||
1425 | if (!pi.FileTime_Defined) | 1418 | if (!pi.FileTime_Defined) |
1426 | { | 1419 | { |
1427 | NCOM::CPropVariant prop; | 1420 | NCOM::CPropVariant prop; |
1428 | RINOK(archive->GetArchiveProperty(kpidCTime, &prop)); | 1421 | RINOK(archive->GetArchiveProperty(kpidCTime, &prop)) |
1429 | if (prop.vt == VT_FILETIME) | 1422 | if (prop.vt == VT_FILETIME) |
1430 | { | 1423 | { |
1431 | pi.FileTime_Defined = true; | 1424 | pi.FileTime_Defined = true; |
@@ -1435,7 +1428,7 @@ static HRESULT ReadParseItemProps(IInArchive *archive, const CArcInfoEx &ai, NAr | |||
1435 | 1428 | ||
1436 | { | 1429 | { |
1437 | NCOM::CPropVariant prop; | 1430 | NCOM::CPropVariant prop; |
1438 | RINOK(archive->GetArchiveProperty(kpidName, &prop)); | 1431 | RINOK(archive->GetArchiveProperty(kpidName, &prop)) |
1439 | if (prop.vt == VT_BSTR) | 1432 | if (prop.vt == VT_BSTR) |
1440 | { | 1433 | { |
1441 | pi.Name.SetFromBstr(prop.bstrVal); | 1434 | pi.Name.SetFromBstr(prop.bstrVal); |
@@ -1443,7 +1436,7 @@ static HRESULT ReadParseItemProps(IInArchive *archive, const CArcInfoEx &ai, NAr | |||
1443 | } | 1436 | } |
1444 | else | 1437 | else |
1445 | { | 1438 | { |
1446 | RINOK(archive->GetArchiveProperty(kpidExtension, &prop)); | 1439 | RINOK(archive->GetArchiveProperty(kpidExtension, &prop)) |
1447 | if (prop.vt == VT_BSTR) | 1440 | if (prop.vt == VT_BSTR) |
1448 | pi.Extension.SetFromBstr(prop.bstrVal); | 1441 | pi.Extension.SetFromBstr(prop.bstrVal); |
1449 | } | 1442 | } |
@@ -1451,14 +1444,14 @@ static HRESULT ReadParseItemProps(IInArchive *archive, const CArcInfoEx &ai, NAr | |||
1451 | 1444 | ||
1452 | { | 1445 | { |
1453 | NCOM::CPropVariant prop; | 1446 | NCOM::CPropVariant prop; |
1454 | RINOK(archive->GetArchiveProperty(kpidShortComment, &prop)); | 1447 | RINOK(archive->GetArchiveProperty(kpidShortComment, &prop)) |
1455 | if (prop.vt == VT_BSTR) | 1448 | if (prop.vt == VT_BSTR) |
1456 | pi.Comment.SetFromBstr(prop.bstrVal); | 1449 | pi.Comment.SetFromBstr(prop.bstrVal); |
1457 | } | 1450 | } |
1458 | 1451 | ||
1459 | 1452 | ||
1460 | UInt32 numItems; | 1453 | UInt32 numItems; |
1461 | RINOK(archive->GetNumberOfItems(&numItems)); | 1454 | RINOK(archive->GetNumberOfItems(&numItems)) |
1462 | 1455 | ||
1463 | // pi.NumSubFiles = numItems; | 1456 | // pi.NumSubFiles = numItems; |
1464 | // RINOK(Archive_GetArcProp_UInt(archive, kpidUnpackSize, pi.UnpackSize, pi.UnpackSize_Defined)); | 1457 | // RINOK(Archive_GetArcProp_UInt(archive, kpidUnpackSize, pi.UnpackSize, pi.UnpackSize_Defined)); |
@@ -1499,14 +1492,14 @@ HRESULT CArc::CheckZerosTail(const COpenOptions &op, UInt64 offset) | |||
1499 | { | 1492 | { |
1500 | if (!op.stream) | 1493 | if (!op.stream) |
1501 | return S_OK; | 1494 | return S_OK; |
1502 | RINOK(op.stream->Seek((Int64)offset, STREAM_SEEK_SET, NULL)); | 1495 | RINOK(InStream_SeekSet(op.stream, offset)) |
1503 | const UInt32 kBufSize = 1 << 11; | 1496 | const UInt32 kBufSize = 1 << 11; |
1504 | Byte buf[kBufSize]; | 1497 | Byte buf[kBufSize]; |
1505 | 1498 | ||
1506 | for (;;) | 1499 | for (;;) |
1507 | { | 1500 | { |
1508 | UInt32 processed = 0; | 1501 | UInt32 processed = 0; |
1509 | RINOK(op.stream->Read(buf, kBufSize, &processed)); | 1502 | RINOK(op.stream->Read(buf, kBufSize, &processed)) |
1510 | if (processed == 0) | 1503 | if (processed == 0) |
1511 | { | 1504 | { |
1512 | // ErrorInfo.NonZerosTail = false; | 1505 | // ErrorInfo.NonZerosTail = false; |
@@ -1527,21 +1520,19 @@ HRESULT CArc::CheckZerosTail(const COpenOptions &op, UInt64 offset) | |||
1527 | 1520 | ||
1528 | 1521 | ||
1529 | 1522 | ||
1530 | #ifndef _SFX | 1523 | #ifndef Z7_SFX |
1531 | 1524 | ||
1532 | class CExtractCallback_To_OpenCallback: | 1525 | Z7_CLASS_IMP_COM_2( |
1533 | public IArchiveExtractCallback, | 1526 | CExtractCallback_To_OpenCallback |
1534 | public ICompressProgressInfo, | 1527 | , IArchiveExtractCallback |
1535 | public CMyUnknownImp | 1528 | , ICompressProgressInfo |
1536 | { | 1529 | ) |
1530 | Z7_IFACE_COM7_IMP(IProgress) | ||
1537 | public: | 1531 | public: |
1538 | CMyComPtr<IArchiveOpenCallback> Callback; | 1532 | CMyComPtr<IArchiveOpenCallback> Callback; |
1539 | UInt64 Files; | 1533 | UInt64 Files; |
1540 | UInt64 Offset; | 1534 | UInt64 Offset; |
1541 | 1535 | ||
1542 | MY_UNKNOWN_IMP2(IArchiveExtractCallback, ICompressProgressInfo) | ||
1543 | INTERFACE_IArchiveExtractCallback(;) | ||
1544 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); | ||
1545 | void Init(IArchiveOpenCallback *callback) | 1536 | void Init(IArchiveOpenCallback *callback) |
1546 | { | 1537 | { |
1547 | Callback = callback; | 1538 | Callback = callback; |
@@ -1550,17 +1541,17 @@ public: | |||
1550 | } | 1541 | } |
1551 | }; | 1542 | }; |
1552 | 1543 | ||
1553 | STDMETHODIMP CExtractCallback_To_OpenCallback::SetTotal(UInt64 /* size */) | 1544 | Z7_COM7F_IMF(CExtractCallback_To_OpenCallback::SetTotal(UInt64 /* size */)) |
1554 | { | 1545 | { |
1555 | return S_OK; | 1546 | return S_OK; |
1556 | } | 1547 | } |
1557 | 1548 | ||
1558 | STDMETHODIMP CExtractCallback_To_OpenCallback::SetCompleted(const UInt64 * /* completeValue */) | 1549 | Z7_COM7F_IMF(CExtractCallback_To_OpenCallback::SetCompleted(const UInt64 * /* completeValue */)) |
1559 | { | 1550 | { |
1560 | return S_OK; | 1551 | return S_OK; |
1561 | } | 1552 | } |
1562 | 1553 | ||
1563 | STDMETHODIMP CExtractCallback_To_OpenCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 * /* outSize */) | 1554 | Z7_COM7F_IMF(CExtractCallback_To_OpenCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 * /* outSize */)) |
1564 | { | 1555 | { |
1565 | if (Callback) | 1556 | if (Callback) |
1566 | { | 1557 | { |
@@ -1572,18 +1563,18 @@ STDMETHODIMP CExtractCallback_To_OpenCallback::SetRatioInfo(const UInt64 *inSize | |||
1572 | return S_OK; | 1563 | return S_OK; |
1573 | } | 1564 | } |
1574 | 1565 | ||
1575 | STDMETHODIMP CExtractCallback_To_OpenCallback::GetStream(UInt32 /* index */, ISequentialOutStream **outStream, Int32 /* askExtractMode */) | 1566 | Z7_COM7F_IMF(CExtractCallback_To_OpenCallback::GetStream(UInt32 /* index */, ISequentialOutStream **outStream, Int32 /* askExtractMode */)) |
1576 | { | 1567 | { |
1577 | *outStream = NULL; | 1568 | *outStream = NULL; |
1578 | return S_OK; | 1569 | return S_OK; |
1579 | } | 1570 | } |
1580 | 1571 | ||
1581 | STDMETHODIMP CExtractCallback_To_OpenCallback::PrepareOperation(Int32 /* askExtractMode */) | 1572 | Z7_COM7F_IMF(CExtractCallback_To_OpenCallback::PrepareOperation(Int32 /* askExtractMode */)) |
1582 | { | 1573 | { |
1583 | return S_OK; | 1574 | return S_OK; |
1584 | } | 1575 | } |
1585 | 1576 | ||
1586 | STDMETHODIMP CExtractCallback_To_OpenCallback::SetOperationResult(Int32 /* operationResult */) | 1577 | Z7_COM7F_IMF(CExtractCallback_To_OpenCallback::SetOperationResult(Int32 /* operationResult */)) |
1587 | { | 1578 | { |
1588 | return S_OK; | 1579 | return S_OK; |
1589 | } | 1580 | } |
@@ -1597,30 +1588,31 @@ static HRESULT OpenArchiveSpec(IInArchive *archive, bool needPhySize, | |||
1597 | /* | 1588 | /* |
1598 | if (needPhySize) | 1589 | if (needPhySize) |
1599 | { | 1590 | { |
1600 | CMyComPtr<IArchiveOpen2> open2; | 1591 | Z7_DECL_CMyComPtr_QI_FROM( |
1601 | archive->QueryInterface(IID_IArchiveOpen2, (void **)&open2); | 1592 | IArchiveOpen2, |
1593 | open2, archive) | ||
1602 | if (open2) | 1594 | if (open2) |
1603 | return open2->ArcOpen2(stream, kOpenFlags_RealPhySize, openCallback); | 1595 | return open2->ArcOpen2(stream, kOpenFlags_RealPhySize, openCallback); |
1604 | } | 1596 | } |
1605 | */ | 1597 | */ |
1606 | RINOK(archive->Open(stream, maxCheckStartPosition, openCallback)); | 1598 | RINOK(archive->Open(stream, maxCheckStartPosition, openCallback)) |
1607 | if (needPhySize) | 1599 | if (needPhySize) |
1608 | { | 1600 | { |
1609 | bool phySize_Defined = false; | 1601 | bool phySize_Defined = false; |
1610 | UInt64 phySize = 0; | 1602 | UInt64 phySize = 0; |
1611 | RINOK(Archive_GetArcProp_UInt(archive, kpidPhySize, phySize, phySize_Defined)); | 1603 | RINOK(Archive_GetArcProp_UInt(archive, kpidPhySize, phySize, phySize_Defined)) |
1612 | if (phySize_Defined) | 1604 | if (phySize_Defined) |
1613 | return S_OK; | 1605 | return S_OK; |
1614 | 1606 | ||
1615 | bool phySizeCantBeDetected = false; | 1607 | bool phySizeCantBeDetected = false; |
1616 | RINOK(Archive_GetArcProp_Bool(archive, kpidPhySizeCantBeDetected, phySizeCantBeDetected)); | 1608 | RINOK(Archive_GetArcProp_Bool(archive, kpidPhySizeCantBeDetected, phySizeCantBeDetected)) |
1617 | 1609 | ||
1618 | if (!phySizeCantBeDetected) | 1610 | if (!phySizeCantBeDetected) |
1619 | { | 1611 | { |
1620 | PRF(printf("\n-- !phySize_Defined after Open, call archive->Extract()")); | 1612 | PRF(printf("\n-- !phySize_Defined after Open, call archive->Extract()")); |
1621 | // It's for bzip2/gz and some xz archives, where Open operation doesn't know phySize. | 1613 | // It's for bzip2/gz and some xz archives, where Open operation doesn't know phySize. |
1622 | // But the Handler will know phySize after full archive testing. | 1614 | // But the Handler will know phySize after full archive testing. |
1623 | RINOK(archive->Extract(NULL, (UInt32)(Int32)-1, BoolToInt(true), extractCallback)); | 1615 | RINOK(archive->Extract(NULL, (UInt32)(Int32)-1, BoolToInt(true), extractCallback)) |
1624 | PRF(printf("\n-- OK")); | 1616 | PRF(printf("\n-- OK")); |
1625 | } | 1617 | } |
1626 | } | 1618 | } |
@@ -1663,7 +1655,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1663 | const UString fileName = ExtractFileNameFromPath(Path); | 1655 | const UString fileName = ExtractFileNameFromPath(Path); |
1664 | UString extension; | 1656 | UString extension; |
1665 | { | 1657 | { |
1666 | int dotPos = fileName.ReverseFind_Dot(); | 1658 | const int dotPos = fileName.ReverseFind_Dot(); |
1667 | if (dotPos >= 0) | 1659 | if (dotPos >= 0) |
1668 | extension = fileName.Ptr((unsigned)(dotPos + 1)); | 1660 | extension = fileName.Ptr((unsigned)(dotPos + 1)); |
1669 | } | 1661 | } |
@@ -1671,7 +1663,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1671 | CIntVector orderIndices; | 1663 | CIntVector orderIndices; |
1672 | 1664 | ||
1673 | bool searchMarkerInHandler = false; | 1665 | bool searchMarkerInHandler = false; |
1674 | #ifdef _SFX | 1666 | #ifdef Z7_SFX |
1675 | searchMarkerInHandler = true; | 1667 | searchMarkerInHandler = true; |
1676 | #endif | 1668 | #endif |
1677 | 1669 | ||
@@ -1681,25 +1673,25 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1681 | isMainFormatArr[i] = false; | 1673 | isMainFormatArr[i] = false; |
1682 | } | 1674 | } |
1683 | 1675 | ||
1684 | UInt64 maxStartOffset = | 1676 | const UInt64 maxStartOffset = |
1685 | op.openType.MaxStartOffset_Defined ? | 1677 | op.openType.MaxStartOffset_Defined ? |
1686 | op.openType.MaxStartOffset : | 1678 | op.openType.MaxStartOffset : |
1687 | kMaxCheckStartPosition; | 1679 | kMaxCheckStartPosition; |
1688 | 1680 | ||
1689 | #ifndef _SFX | 1681 | #ifndef Z7_SFX |
1690 | bool isUnknownExt = false; | 1682 | bool isUnknownExt = false; |
1691 | #endif | 1683 | #endif |
1692 | 1684 | ||
1693 | #ifndef _SFX | 1685 | #ifndef Z7_SFX |
1694 | bool isForced = false; | 1686 | bool isForced = false; |
1695 | #endif | 1687 | #endif |
1696 | 1688 | ||
1697 | unsigned numMainTypes = 0; | 1689 | unsigned numMainTypes = 0; |
1698 | int formatIndex = op.openType.FormatIndex; | 1690 | const int formatIndex = op.openType.FormatIndex; |
1699 | 1691 | ||
1700 | if (formatIndex >= 0) | 1692 | if (formatIndex >= 0) |
1701 | { | 1693 | { |
1702 | #ifndef _SFX | 1694 | #ifndef Z7_SFX |
1703 | isForced = true; | 1695 | isForced = true; |
1704 | #endif | 1696 | #endif |
1705 | orderIndices.Add(formatIndex); | 1697 | orderIndices.Add(formatIndex); |
@@ -1711,12 +1703,12 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1711 | else | 1703 | else |
1712 | { | 1704 | { |
1713 | unsigned numFinded = 0; | 1705 | unsigned numFinded = 0; |
1714 | #ifndef _SFX | 1706 | #ifndef Z7_SFX |
1715 | bool isPrearcExt = false; | 1707 | bool isPrearcExt = false; |
1716 | #endif | 1708 | #endif |
1717 | 1709 | ||
1718 | { | 1710 | { |
1719 | #ifndef _SFX | 1711 | #ifndef Z7_SFX |
1720 | 1712 | ||
1721 | bool isZip = false; | 1713 | bool isZip = false; |
1722 | bool isRar = false; | 1714 | bool isRar = false; |
@@ -1758,13 +1750,13 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1758 | if (op.excludedFormats->FindInSorted((int)i) >= 0) | 1750 | if (op.excludedFormats->FindInSorted((int)i) >= 0) |
1759 | continue; | 1751 | continue; |
1760 | 1752 | ||
1761 | #ifndef _SFX | 1753 | #ifndef Z7_SFX |
1762 | if (IsPreArcFormat(ai)) | 1754 | if (IsPreArcFormat(ai)) |
1763 | isPrearcExt = true; | 1755 | isPrearcExt = true; |
1764 | #endif | 1756 | #endif |
1765 | 1757 | ||
1766 | if (ai.FindExtension(extension) >= 0 | 1758 | if (ai.FindExtension(extension) >= 0 |
1767 | #ifndef _SFX | 1759 | #ifndef Z7_SFX |
1768 | || (isZip && ai.Is_Zip()) | 1760 | || (isZip && ai.Is_Zip()) |
1769 | || (isRar && ai.Is_Rar()) | 1761 | || (isRar && ai.Is_Rar()) |
1770 | #endif | 1762 | #endif |
@@ -1795,11 +1787,11 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1795 | } | 1787 | } |
1796 | */ | 1788 | */ |
1797 | 1789 | ||
1798 | #ifndef _SFX | 1790 | #ifndef Z7_SFX |
1799 | 1791 | ||
1800 | if (op.stream && orderIndices.Size() >= 2) | 1792 | if (op.stream && orderIndices.Size() >= 2) |
1801 | { | 1793 | { |
1802 | RINOK(op.stream->Seek(0, STREAM_SEEK_SET, NULL)); | 1794 | RINOK(InStream_SeekToBegin(op.stream)) |
1803 | CByteBuffer byteBuffer; | 1795 | CByteBuffer byteBuffer; |
1804 | CIntVector orderIndices2; | 1796 | CIntVector orderIndices2; |
1805 | if (numFinded == 0 || IsExeExt(extension)) | 1797 | if (numFinded == 0 || IsExeExt(extension)) |
@@ -1808,13 +1800,13 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1808 | } | 1800 | } |
1809 | else if (extension.IsEqualTo("000") || extension.IsEqualTo("001")) | 1801 | else if (extension.IsEqualTo("000") || extension.IsEqualTo("001")) |
1810 | { | 1802 | { |
1811 | int i = FindFormatForArchiveType(op.codecs, orderIndices, "rar"); | 1803 | const int i = FindFormatForArchiveType(op.codecs, orderIndices, "rar"); |
1812 | if (i >= 0) | 1804 | if (i >= 0) |
1813 | { | 1805 | { |
1814 | const size_t kBufSize = (1 << 10); | 1806 | const size_t kBufSize = (1 << 10); |
1815 | byteBuffer.Alloc(kBufSize); | 1807 | byteBuffer.Alloc(kBufSize); |
1816 | size_t processedSize = kBufSize; | 1808 | size_t processedSize = kBufSize; |
1817 | RINOK(ReadStream(op.stream, byteBuffer, &processedSize)); | 1809 | RINOK(ReadStream(op.stream, byteBuffer, &processedSize)) |
1818 | if (processedSize >= 16) | 1810 | if (processedSize >= 16) |
1819 | { | 1811 | { |
1820 | const Byte *buf = byteBuffer; | 1812 | const Byte *buf = byteBuffer; |
@@ -1834,7 +1826,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1834 | const size_t kBufSize = (1 << 10); | 1826 | const size_t kBufSize = (1 << 10); |
1835 | byteBuffer.Alloc(kBufSize); | 1827 | byteBuffer.Alloc(kBufSize); |
1836 | size_t processedSize = kBufSize; | 1828 | size_t processedSize = kBufSize; |
1837 | RINOK(ReadStream(op.stream, byteBuffer, &processedSize)); | 1829 | RINOK(ReadStream(op.stream, byteBuffer, &processedSize)) |
1838 | if (processedSize == 0) | 1830 | if (processedSize == 0) |
1839 | return S_FALSE; | 1831 | return S_FALSE; |
1840 | 1832 | ||
@@ -1870,7 +1862,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1870 | 1862 | ||
1871 | FOR_VECTOR (i, orderIndices) | 1863 | FOR_VECTOR (i, orderIndices) |
1872 | { | 1864 | { |
1873 | int val = orderIndices[i]; | 1865 | const int val = orderIndices[i]; |
1874 | if (val != -1) | 1866 | if (val != -1) |
1875 | orderIndices2.Add(val); | 1867 | orderIndices2.Add(val); |
1876 | } | 1868 | } |
@@ -1879,12 +1871,12 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1879 | 1871 | ||
1880 | if (orderIndices.Size() >= 2) | 1872 | if (orderIndices.Size() >= 2) |
1881 | { | 1873 | { |
1882 | int iIso = FindFormatForArchiveType(op.codecs, orderIndices, "iso"); | 1874 | const int iIso = FindFormatForArchiveType(op.codecs, orderIndices, "iso"); |
1883 | int iUdf = FindFormatForArchiveType(op.codecs, orderIndices, "udf"); | 1875 | const int iUdf = FindFormatForArchiveType(op.codecs, orderIndices, "udf"); |
1884 | if (iUdf > iIso && iIso >= 0) | 1876 | if (iUdf > iIso && iIso >= 0) |
1885 | { | 1877 | { |
1886 | int isoIndex = orderIndices[(unsigned)iIso]; | 1878 | const int isoIndex = orderIndices[(unsigned)iIso]; |
1887 | int udfIndex = orderIndices[(unsigned)iUdf]; | 1879 | const int udfIndex = orderIndices[(unsigned)iUdf]; |
1888 | orderIndices[(unsigned)iUdf] = isoIndex; | 1880 | orderIndices[(unsigned)iUdf] = isoIndex; |
1889 | orderIndices[(unsigned)iIso] = udfIndex; | 1881 | orderIndices[(unsigned)iIso] = udfIndex; |
1890 | } | 1882 | } |
@@ -1893,7 +1885,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1893 | numMainTypes = numFinded; | 1885 | numMainTypes = numFinded; |
1894 | isUnknownExt = (numMainTypes == 0) || isPrearcExt; | 1886 | isUnknownExt = (numMainTypes == 0) || isPrearcExt; |
1895 | 1887 | ||
1896 | #else // _SFX | 1888 | #else // Z7_SFX |
1897 | 1889 | ||
1898 | numMainTypes = orderIndices.Size(); | 1890 | numMainTypes = orderIndices.Size(); |
1899 | 1891 | ||
@@ -1907,13 +1899,12 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1907 | UInt64 fileSize = 0; | 1899 | UInt64 fileSize = 0; |
1908 | if (op.stream) | 1900 | if (op.stream) |
1909 | { | 1901 | { |
1910 | RINOK(op.stream->Seek(0, STREAM_SEEK_END, &fileSize)); | 1902 | RINOK(InStream_GetSize_SeekToBegin(op.stream, fileSize)) |
1911 | RINOK(op.stream->Seek(0, STREAM_SEEK_SET, NULL)); | ||
1912 | } | 1903 | } |
1913 | FileSize = fileSize; | 1904 | FileSize = fileSize; |
1914 | 1905 | ||
1915 | 1906 | ||
1916 | #ifndef _SFX | 1907 | #ifndef Z7_SFX |
1917 | 1908 | ||
1918 | CBoolArr skipFrontalFormat(op.codecs->Formats.Size()); | 1909 | CBoolArr skipFrontalFormat(op.codecs->Formats.Size()); |
1919 | { | 1910 | { |
@@ -1945,7 +1936,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1945 | 1936 | ||
1946 | bool exactOnly = false; | 1937 | bool exactOnly = false; |
1947 | 1938 | ||
1948 | #ifndef _SFX | 1939 | #ifndef Z7_SFX |
1949 | 1940 | ||
1950 | const CArcInfoEx &ai = op.codecs->Formats[(unsigned)FormatIndex]; | 1941 | const CArcInfoEx &ai = op.codecs->Formats[(unsigned)FormatIndex]; |
1951 | // OutputDebugStringW(ai.Name); | 1942 | // OutputDebugStringW(ai.Name); |
@@ -1963,16 +1954,16 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1963 | 1954 | ||
1964 | // Some handlers do not set total bytes. So we set it here | 1955 | // Some handlers do not set total bytes. So we set it here |
1965 | if (op.callback) | 1956 | if (op.callback) |
1966 | RINOK(op.callback->SetTotal(NULL, &fileSize)); | 1957 | RINOK(op.callback->SetTotal(NULL, &fileSize)) |
1967 | 1958 | ||
1968 | if (op.stream) | 1959 | if (op.stream) |
1969 | { | 1960 | { |
1970 | RINOK(op.stream->Seek(0, STREAM_SEEK_SET, NULL)); | 1961 | RINOK(InStream_SeekToBegin(op.stream)) |
1971 | } | 1962 | } |
1972 | 1963 | ||
1973 | CMyComPtr<IInArchive> archive; | 1964 | CMyComPtr<IInArchive> archive; |
1974 | 1965 | ||
1975 | RINOK(PrepareToOpen(op, (unsigned)FormatIndex, archive)); | 1966 | RINOK(PrepareToOpen(op, (unsigned)FormatIndex, archive)) |
1976 | if (!archive) | 1967 | if (!archive) |
1977 | continue; | 1968 | continue; |
1978 | 1969 | ||
@@ -1991,13 +1982,13 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
1991 | result = openSeq->OpenSeq(op.seqStream); | 1982 | result = openSeq->OpenSeq(op.seqStream); |
1992 | } | 1983 | } |
1993 | 1984 | ||
1994 | RINOK(ReadBasicProps(archive, 0, result)); | 1985 | RINOK(ReadBasicProps(archive, 0, result)) |
1995 | 1986 | ||
1996 | if (result == S_FALSE) | 1987 | if (result == S_FALSE) |
1997 | { | 1988 | { |
1998 | bool isArc = ErrorInfo.IsArc_After_NonOpen(); | 1989 | bool isArc = ErrorInfo.IsArc_After_NonOpen(); |
1999 | 1990 | ||
2000 | #ifndef _SFX | 1991 | #ifndef Z7_SFX |
2001 | // if it's archive, we allow another open attempt for parser | 1992 | // if it's archive, we allow another open attempt for parser |
2002 | if (!mode.CanReturnParser || !isArc) | 1993 | if (!mode.CanReturnParser || !isArc) |
2003 | skipFrontalFormat[(unsigned)FormatIndex] = true; | 1994 | skipFrontalFormat[(unsigned)FormatIndex] = true; |
@@ -2017,7 +2008,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2017 | // if (formatIndex < 0 && !searchMarkerInHandler) | 2008 | // if (formatIndex < 0 && !searchMarkerInHandler) |
2018 | { | 2009 | { |
2019 | // if bad archive was detected, we don't need additional open attempts | 2010 | // if bad archive was detected, we don't need additional open attempts |
2020 | #ifndef _SFX | 2011 | #ifndef Z7_SFX |
2021 | if (!IsPreArcFormat(ai) /* || !mode.SkipSfxStub */) | 2012 | if (!IsPreArcFormat(ai) /* || !mode.SkipSfxStub */) |
2022 | #endif | 2013 | #endif |
2023 | return S_FALSE; | 2014 | return S_FALSE; |
@@ -2026,7 +2017,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2026 | } | 2017 | } |
2027 | 2018 | ||
2028 | /* | 2019 | /* |
2029 | #ifndef _SFX | 2020 | #ifndef Z7_SFX |
2030 | if (IsExeExt(extension) || ai.Flags_PreArc()) | 2021 | if (IsExeExt(extension) || ai.Flags_PreArc()) |
2031 | { | 2022 | { |
2032 | // openOnlyFullArc = false; | 2023 | // openOnlyFullArc = false; |
@@ -2039,9 +2030,9 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2039 | continue; | 2030 | continue; |
2040 | } | 2031 | } |
2041 | 2032 | ||
2042 | RINOK(result); | 2033 | RINOK(result) |
2043 | 2034 | ||
2044 | #ifndef _SFX | 2035 | #ifndef Z7_SFX |
2045 | 2036 | ||
2046 | bool isMainFormat = isMainFormatArr[(unsigned)FormatIndex]; | 2037 | bool isMainFormat = isMainFormatArr[(unsigned)FormatIndex]; |
2047 | const COpenSpecFlags &specFlags = mode.GetSpec(isForced, isMainFormat, isUnknownExt); | 2038 | const COpenSpecFlags &specFlags = mode.GetSpec(isForced, isMainFormat, isUnknownExt); |
@@ -2049,7 +2040,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2049 | bool thereIsTail = ErrorInfo.ThereIsTail; | 2040 | bool thereIsTail = ErrorInfo.ThereIsTail; |
2050 | if (thereIsTail && mode.ZerosTailIsAllowed) | 2041 | if (thereIsTail && mode.ZerosTailIsAllowed) |
2051 | { | 2042 | { |
2052 | RINOK(CheckZerosTail(op, (UInt64)(Offset + (Int64)PhySize))); | 2043 | RINOK(CheckZerosTail(op, (UInt64)(Offset + (Int64)PhySize))) |
2053 | if (ErrorInfo.IgnoreTail) | 2044 | if (ErrorInfo.IgnoreTail) |
2054 | thereIsTail = false; | 2045 | thereIsTail = false; |
2055 | } | 2046 | } |
@@ -2103,7 +2094,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2103 | 2094 | ||
2104 | 2095 | ||
2105 | 2096 | ||
2106 | #ifndef _SFX | 2097 | #ifndef Z7_SFX |
2107 | 2098 | ||
2108 | if (!op.stream) | 2099 | if (!op.stream) |
2109 | return S_FALSE; | 2100 | return S_FALSE; |
@@ -2148,9 +2139,9 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2148 | endOfFile = true; | 2139 | endOfFile = true; |
2149 | } | 2140 | } |
2150 | byteBuffer.Alloc(bufSize); | 2141 | byteBuffer.Alloc(bufSize); |
2151 | RINOK(op.stream->Seek(0, STREAM_SEEK_SET, NULL)); | 2142 | RINOK(InStream_SeekToBegin(op.stream)) |
2152 | processedSize = bufSize; | 2143 | processedSize = bufSize; |
2153 | RINOK(ReadStream(op.stream, byteBuffer, &processedSize)); | 2144 | RINOK(ReadStream(op.stream, byteBuffer, &processedSize)) |
2154 | if (processedSize == 0) | 2145 | if (processedSize == 0) |
2155 | return S_FALSE; | 2146 | return S_FALSE; |
2156 | if (processedSize < bufSize) | 2147 | if (processedSize < bufSize) |
@@ -2232,12 +2223,12 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2232 | const CArcInfoEx &ai = op.codecs->Formats[(unsigned)FormatIndex]; | 2223 | const CArcInfoEx &ai = op.codecs->Formats[(unsigned)FormatIndex]; |
2233 | 2224 | ||
2234 | if (op.callback) | 2225 | if (op.callback) |
2235 | RINOK(op.callback->SetTotal(NULL, &fileSize)); | 2226 | RINOK(op.callback->SetTotal(NULL, &fileSize)) |
2236 | 2227 | ||
2237 | RINOK(op.stream->Seek(0, STREAM_SEEK_SET, NULL)); | 2228 | RINOK(InStream_SeekToBegin(op.stream)) |
2238 | 2229 | ||
2239 | CMyComPtr<IInArchive> archive; | 2230 | CMyComPtr<IInArchive> archive; |
2240 | RINOK(PrepareToOpen(op, (unsigned)FormatIndex, archive)); | 2231 | RINOK(PrepareToOpen(op, (unsigned)FormatIndex, archive)) |
2241 | if (!archive) | 2232 | if (!archive) |
2242 | continue; | 2233 | continue; |
2243 | 2234 | ||
@@ -2263,9 +2254,9 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2263 | // printf(" OpenForSize Error"); | 2254 | // printf(" OpenForSize Error"); |
2264 | continue; | 2255 | continue; |
2265 | } | 2256 | } |
2266 | RINOK(result); | 2257 | RINOK(result) |
2267 | 2258 | ||
2268 | RINOK(ReadBasicProps(archive, 0, result)); | 2259 | RINOK(ReadBasicProps(archive, 0, result)) |
2269 | 2260 | ||
2270 | if (Offset > 0) | 2261 | if (Offset > 0) |
2271 | { | 2262 | { |
@@ -2302,7 +2293,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2302 | 2293 | ||
2303 | if (mode.CanReturnArc) | 2294 | if (mode.CanReturnArc) |
2304 | { | 2295 | { |
2305 | bool isMainFormat = isMainFormatArr[(unsigned)FormatIndex]; | 2296 | const bool isMainFormat = isMainFormatArr[(unsigned)FormatIndex]; |
2306 | const COpenSpecFlags &specFlags = mode.GetSpec(isForced, isMainFormat, isUnknownExt); | 2297 | const COpenSpecFlags &specFlags = mode.GetSpec(isForced, isMainFormat, isUnknownExt); |
2307 | bool openCur = false; | 2298 | bool openCur = false; |
2308 | 2299 | ||
@@ -2312,7 +2303,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2312 | { | 2303 | { |
2313 | if (mode.ZerosTailIsAllowed) | 2304 | if (mode.ZerosTailIsAllowed) |
2314 | { | 2305 | { |
2315 | RINOK(CheckZerosTail(op, (UInt64)(Offset + (Int64)PhySize))); | 2306 | RINOK(CheckZerosTail(op, (UInt64)(Offset + (Int64)PhySize))) |
2316 | if (ErrorInfo.IgnoreTail) | 2307 | if (ErrorInfo.IgnoreTail) |
2317 | openCur = true; | 2308 | openCur = true; |
2318 | } | 2309 | } |
@@ -2352,7 +2343,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2352 | continue; | 2343 | continue; |
2353 | 2344 | ||
2354 | // printf("\nAdd offset = %d", (int)pi.Offset); | 2345 | // printf("\nAdd offset = %d", (int)pi.Offset); |
2355 | RINOK(ReadParseItemProps(archive, ai, pi)); | 2346 | RINOK(ReadParseItemProps(archive, ai, pi)) |
2356 | handlerSpec->AddItem(pi); | 2347 | handlerSpec->AddItem(pi); |
2357 | } | 2348 | } |
2358 | } | 2349 | } |
@@ -2451,7 +2442,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2451 | // canReturnTailArc = true; | 2442 | // canReturnTailArc = true; |
2452 | } | 2443 | } |
2453 | 2444 | ||
2454 | RINOK(op.stream->Seek(0, STREAM_SEEK_SET, NULL)); | 2445 | RINOK(InStream_SeekToBegin(op.stream)) |
2455 | 2446 | ||
2456 | CLimitedCachedInStream *limitedStreamSpec = new CLimitedCachedInStream; | 2447 | CLimitedCachedInStream *limitedStreamSpec = new CLimitedCachedInStream; |
2457 | CMyComPtr<IInStream> limitedStream = limitedStreamSpec; | 2448 | CMyComPtr<IInStream> limitedStream = limitedStreamSpec; |
@@ -2465,13 +2456,13 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2465 | openCallback_Offset = openCallback_Offset_Spec; | 2456 | openCallback_Offset = openCallback_Offset_Spec; |
2466 | openCallback_Offset_Spec->Callback = op.callback; | 2457 | openCallback_Offset_Spec->Callback = op.callback; |
2467 | openCallback_Offset_Spec->Callback.QueryInterface(IID_IArchiveOpenVolumeCallback, &openCallback_Offset_Spec->OpenVolumeCallback); | 2458 | openCallback_Offset_Spec->Callback.QueryInterface(IID_IArchiveOpenVolumeCallback, &openCallback_Offset_Spec->OpenVolumeCallback); |
2468 | #ifndef _NO_CRYPTO | 2459 | #ifndef Z7_NO_CRYPTO |
2469 | openCallback_Offset_Spec->Callback.QueryInterface(IID_ICryptoGetTextPassword, &openCallback_Offset_Spec->GetTextPassword); | 2460 | openCallback_Offset_Spec->Callback.QueryInterface(IID_ICryptoGetTextPassword, &openCallback_Offset_Spec->GetTextPassword); |
2470 | #endif | 2461 | #endif |
2471 | } | 2462 | } |
2472 | 2463 | ||
2473 | if (op.callback) | 2464 | if (op.callback) |
2474 | RINOK(op.callback->SetTotal(NULL, &fileSize)); | 2465 | RINOK(op.callback->SetTotal(NULL, &fileSize)) |
2475 | 2466 | ||
2476 | CByteBuffer &byteBuffer = limitedStreamSpec->Buffer; | 2467 | CByteBuffer &byteBuffer = limitedStreamSpec->Buffer; |
2477 | byteBuffer.Alloc(kBufSize); | 2468 | byteBuffer.Alloc(kBufSize); |
@@ -2509,8 +2500,8 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2509 | size_t processedSize = kBufSize - bytesInBuf; | 2500 | size_t processedSize = kBufSize - bytesInBuf; |
2510 | // printf("\nRead ask = %d", (unsigned)processedSize); | 2501 | // printf("\nRead ask = %d", (unsigned)processedSize); |
2511 | UInt64 seekPos = bufPhyPos + bytesInBuf; | 2502 | UInt64 seekPos = bufPhyPos + bytesInBuf; |
2512 | RINOK(op.stream->Seek((Int64)(bufPhyPos + bytesInBuf), STREAM_SEEK_SET, NULL)); | 2503 | RINOK(InStream_SeekSet(op.stream, bufPhyPos + bytesInBuf)) |
2513 | RINOK(ReadStream(op.stream, byteBuffer + bytesInBuf, &processedSize)); | 2504 | RINOK(ReadStream(op.stream, byteBuffer + bytesInBuf, &processedSize)) |
2514 | // printf(" processed = %d", (unsigned)processedSize); | 2505 | // printf(" processed = %d", (unsigned)processedSize); |
2515 | if (processedSize == 0) | 2506 | if (processedSize == 0) |
2516 | { | 2507 | { |
@@ -2568,7 +2559,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2568 | 2559 | ||
2569 | if (pos >= callbackPrev + (1 << 23)) | 2560 | if (pos >= callbackPrev + (1 << 23)) |
2570 | { | 2561 | { |
2571 | RINOK(openCallback_Offset_Spec->SetCompleted(NULL, NULL)); | 2562 | RINOK(openCallback_Offset->SetCompleted(NULL, NULL)) |
2572 | callbackPrev = pos; | 2563 | callbackPrev = pos; |
2573 | } | 2564 | } |
2574 | } | 2565 | } |
@@ -2691,10 +2682,10 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2691 | 2682 | ||
2692 | if (ai.IsArcFunc && startArcPos >= bufPhyPos) | 2683 | if (ai.IsArcFunc && startArcPos >= bufPhyPos) |
2693 | { | 2684 | { |
2694 | size_t offsetInBuf = (size_t)(startArcPos - bufPhyPos); | 2685 | const size_t offsetInBuf = (size_t)(startArcPos - bufPhyPos); |
2695 | if (offsetInBuf < bytesInBuf) | 2686 | if (offsetInBuf < bytesInBuf) |
2696 | { | 2687 | { |
2697 | UInt32 isArcRes = ai.IsArcFunc(byteBuffer + offsetInBuf, bytesInBuf - offsetInBuf); | 2688 | const UInt32 isArcRes = ai.IsArcFunc(byteBuffer + offsetInBuf, bytesInBuf - offsetInBuf); |
2698 | if (isArcRes == k_IsArc_Res_NO) | 2689 | if (isArcRes == k_IsArc_Res_NO) |
2699 | continue; | 2690 | continue; |
2700 | if (isArcRes == k_IsArc_Res_NEED_MORE && endOfFile) | 2691 | if (isArcRes == k_IsArc_Res_NEED_MORE && endOfFile) |
@@ -2716,7 +2707,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2716 | const COpenSpecFlags &specFlags = mode.GetSpec(isForced, isMainFormat, isUnknownExt); | 2707 | const COpenSpecFlags &specFlags = mode.GetSpec(isForced, isMainFormat, isUnknownExt); |
2717 | 2708 | ||
2718 | CMyComPtr<IInArchive> archive; | 2709 | CMyComPtr<IInArchive> archive; |
2719 | RINOK(PrepareToOpen(op, index, archive)); | 2710 | RINOK(PrepareToOpen(op, index, archive)) |
2720 | if (!archive) | 2711 | if (!archive) |
2721 | return E_FAIL; | 2712 | return E_FAIL; |
2722 | 2713 | ||
@@ -2728,12 +2719,12 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2728 | 2719 | ||
2729 | if (ai.Flags_UseGlobalOffset()) | 2720 | if (ai.Flags_UseGlobalOffset()) |
2730 | { | 2721 | { |
2731 | limitedStreamSpec->InitAndSeek(0, fileSize); | 2722 | RINOK(limitedStreamSpec->InitAndSeek(0, fileSize)) |
2732 | limitedStream->Seek((Int64)startArcPos, STREAM_SEEK_SET, NULL); | 2723 | RINOK(InStream_SeekSet(limitedStream, startArcPos)) |
2733 | } | 2724 | } |
2734 | else | 2725 | else |
2735 | { | 2726 | { |
2736 | limitedStreamSpec->InitAndSeek(startArcPos, rem); | 2727 | RINOK(limitedStreamSpec->InitAndSeek(startArcPos, rem)) |
2737 | arcStreamOffset = startArcPos; | 2728 | arcStreamOffset = startArcPos; |
2738 | } | 2729 | } |
2739 | 2730 | ||
@@ -2755,7 +2746,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2755 | useOffsetCallback ? (IArchiveOpenCallback *)openCallback_Offset : (IArchiveOpenCallback *)op.callback, | 2746 | useOffsetCallback ? (IArchiveOpenCallback *)openCallback_Offset : (IArchiveOpenCallback *)op.callback, |
2756 | extractCallback_To_OpenCallback); | 2747 | extractCallback_To_OpenCallback); |
2757 | 2748 | ||
2758 | RINOK(ReadBasicProps(archive, ai.Flags_UseGlobalOffset() ? 0 : startArcPos, result)); | 2749 | RINOK(ReadBasicProps(archive, ai.Flags_UseGlobalOffset() ? 0 : startArcPos, result)) |
2759 | 2750 | ||
2760 | bool isOpen = false; | 2751 | bool isOpen = false; |
2761 | 2752 | ||
@@ -2784,7 +2775,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2784 | continue; | 2775 | continue; |
2785 | } | 2776 | } |
2786 | isOpen = true; | 2777 | isOpen = true; |
2787 | RINOK(result); | 2778 | RINOK(result) |
2788 | PRF(printf(" OK ")); | 2779 | PRF(printf(" OK ")); |
2789 | } | 2780 | } |
2790 | 2781 | ||
@@ -2874,7 +2865,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2874 | pos = pi.Offset + pi.Size; | 2865 | pos = pi.Offset + pi.Size; |
2875 | 2866 | ||
2876 | 2867 | ||
2877 | RINOK(ReadParseItemProps(archive, ai, pi)); | 2868 | RINOK(ReadParseItemProps(archive, ai, pi)) |
2878 | 2869 | ||
2879 | if (pi.Offset < startArcPos && !mode.EachPos /* && phySize_Defined */) | 2870 | if (pi.Offset < startArcPos && !mode.EachPos /* && phySize_Defined */) |
2880 | { | 2871 | { |
@@ -2903,7 +2894,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
2903 | bool thereIsTail = ErrorInfo.ThereIsTail; | 2894 | bool thereIsTail = ErrorInfo.ThereIsTail; |
2904 | if (thereIsTail && mode.ZerosTailIsAllowed) | 2895 | if (thereIsTail && mode.ZerosTailIsAllowed) |
2905 | { | 2896 | { |
2906 | RINOK(CheckZerosTail(op, (UInt64)((Int64)arcStreamOffset + Offset + (Int64)PhySize))); | 2897 | RINOK(CheckZerosTail(op, (UInt64)((Int64)arcStreamOffset + Offset + (Int64)PhySize))) |
2907 | if (ErrorInfo.IgnoreTail) | 2898 | if (ErrorInfo.IgnoreTail) |
2908 | thereIsTail = false; | 2899 | thereIsTail = false; |
2909 | } | 2900 | } |
@@ -3029,7 +3020,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op) | |||
3029 | 3020 | ||
3030 | HRESULT CArc::OpenStream(const COpenOptions &op) | 3021 | HRESULT CArc::OpenStream(const COpenOptions &op) |
3031 | { | 3022 | { |
3032 | RINOK(OpenStream2(op)); | 3023 | RINOK(OpenStream2(op)) |
3033 | // PrintNumber("op.formatIndex 3", op.formatIndex); | 3024 | // PrintNumber("op.formatIndex 3", op.formatIndex); |
3034 | 3025 | ||
3035 | if (Archive) | 3026 | if (Archive) |
@@ -3039,12 +3030,12 @@ HRESULT CArc::OpenStream(const COpenOptions &op) | |||
3039 | Archive->QueryInterface(IID_IArchiveGetRawProps, (void **)&GetRawProps); | 3030 | Archive->QueryInterface(IID_IArchiveGetRawProps, (void **)&GetRawProps); |
3040 | Archive->QueryInterface(IID_IArchiveGetRootProps, (void **)&GetRootProps); | 3031 | Archive->QueryInterface(IID_IArchiveGetRootProps, (void **)&GetRootProps); |
3041 | 3032 | ||
3042 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsTree, IsTree)); | 3033 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsTree, IsTree)) |
3043 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsDeleted, Ask_Deleted)); | 3034 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsDeleted, Ask_Deleted)) |
3044 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsAltStream, Ask_AltStream)); | 3035 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsAltStream, Ask_AltStream)) |
3045 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsAux, Ask_Aux)); | 3036 | RINOK(Archive_GetArcProp_Bool(Archive, kpidIsAux, Ask_Aux)) |
3046 | RINOK(Archive_GetArcProp_Bool(Archive, kpidINode, Ask_INode)); | 3037 | RINOK(Archive_GetArcProp_Bool(Archive, kpidINode, Ask_INode)) |
3047 | RINOK(Archive_GetArcProp_Bool(Archive, kpidReadOnly, IsReadOnly)); | 3038 | RINOK(Archive_GetArcProp_Bool(Archive, kpidReadOnly, IsReadOnly)) |
3048 | 3039 | ||
3049 | const UString fileName = ExtractFileNameFromPath(Path); | 3040 | const UString fileName = ExtractFileNameFromPath(Path); |
3050 | UString extension; | 3041 | UString extension; |
@@ -3074,7 +3065,7 @@ HRESULT CArc::OpenStream(const COpenOptions &op) | |||
3074 | return S_OK; | 3065 | return S_OK; |
3075 | } | 3066 | } |
3076 | 3067 | ||
3077 | #ifdef _SFX | 3068 | #ifdef Z7_SFX |
3078 | 3069 | ||
3079 | #ifdef _WIN32 | 3070 | #ifdef _WIN32 |
3080 | #define k_ExeExt ".exe" | 3071 | #define k_ExeExt ".exe" |
@@ -3105,7 +3096,7 @@ HRESULT CArc::OpenStreamOrFile(COpenOptions &op) | |||
3105 | if (!fileStreamSpec->Open(us2fs(Path))) | 3096 | if (!fileStreamSpec->Open(us2fs(Path))) |
3106 | return GetLastError_noZero_HRESULT(); | 3097 | return GetLastError_noZero_HRESULT(); |
3107 | op.stream = fileStream; | 3098 | op.stream = fileStream; |
3108 | #ifdef _SFX | 3099 | #ifdef Z7_SFX |
3109 | IgnoreSplit = true; | 3100 | IgnoreSplit = true; |
3110 | #endif | 3101 | #endif |
3111 | } | 3102 | } |
@@ -3114,7 +3105,7 @@ HRESULT CArc::OpenStreamOrFile(COpenOptions &op) | |||
3114 | if (callback) | 3105 | if (callback) |
3115 | { | 3106 | { |
3116 | UInt64 fileSize; | 3107 | UInt64 fileSize; |
3117 | RINOK(op.stream->Seek(0, STREAM_SEEK_END, &fileSize)); | 3108 | RINOK(InStream_GetSize_SeekToEnd(op.stream, fileSize)); |
3118 | RINOK(op.callback->SetTotal(NULL, &fileSize)) | 3109 | RINOK(op.callback->SetTotal(NULL, &fileSize)) |
3119 | } | 3110 | } |
3120 | */ | 3111 | */ |
@@ -3122,7 +3113,7 @@ HRESULT CArc::OpenStreamOrFile(COpenOptions &op) | |||
3122 | HRESULT res = OpenStream(op); | 3113 | HRESULT res = OpenStream(op); |
3123 | IgnoreSplit = false; | 3114 | IgnoreSplit = false; |
3124 | 3115 | ||
3125 | #ifdef _SFX | 3116 | #ifdef Z7_SFX |
3126 | 3117 | ||
3127 | if (res != S_FALSE | 3118 | if (res != S_FALSE |
3128 | || !fileStreamSpec | 3119 | || !fileStreamSpec |
@@ -3141,7 +3132,7 @@ HRESULT CArc::OpenStreamOrFile(COpenOptions &op) | |||
3141 | if (ai.Is_Split()) | 3132 | if (ai.Is_Split()) |
3142 | continue; | 3133 | continue; |
3143 | UString path3 = path2; | 3134 | UString path3 = path2; |
3144 | path3 += '.'; | 3135 | path3.Add_Dot(); |
3145 | path3 += ai.GetMainExt(); // "7z" for SFX. | 3136 | path3 += ai.GetMainExt(); // "7z" for SFX. |
3146 | Path = path3; | 3137 | Path = path3; |
3147 | Path += ".001"; | 3138 | Path += ".001"; |
@@ -3187,7 +3178,7 @@ HRESULT CArchiveLink::Close() | |||
3187 | for (unsigned i = Arcs.Size(); i != 0;) | 3178 | for (unsigned i = Arcs.Size(); i != 0;) |
3188 | { | 3179 | { |
3189 | i--; | 3180 | i--; |
3190 | RINOK(Arcs[i].Close()); | 3181 | RINOK(Arcs[i].Close()) |
3191 | } | 3182 | } |
3192 | IsOpen = false; | 3183 | IsOpen = false; |
3193 | // ErrorsText.Empty(); | 3184 | // ErrorsText.Empty(); |
@@ -3320,13 +3311,13 @@ HRESULT CArchiveLink::Open(COpenOptions &op) | |||
3320 | UInt32 mainSubfile; | 3311 | UInt32 mainSubfile; |
3321 | { | 3312 | { |
3322 | NCOM::CPropVariant prop; | 3313 | NCOM::CPropVariant prop; |
3323 | RINOK(arc.Archive->GetArchiveProperty(kpidMainSubfile, &prop)); | 3314 | RINOK(arc.Archive->GetArchiveProperty(kpidMainSubfile, &prop)) |
3324 | if (prop.vt == VT_UI4) | 3315 | if (prop.vt == VT_UI4) |
3325 | mainSubfile = prop.ulVal; | 3316 | mainSubfile = prop.ulVal; |
3326 | else | 3317 | else |
3327 | break; | 3318 | break; |
3328 | UInt32 numItems; | 3319 | UInt32 numItems; |
3329 | RINOK(arc.Archive->GetNumberOfItems(&numItems)); | 3320 | RINOK(arc.Archive->GetNumberOfItems(&numItems)) |
3330 | if (mainSubfile >= numItems) | 3321 | if (mainSubfile >= numItems) |
3331 | break; | 3322 | break; |
3332 | } | 3323 | } |
@@ -3345,16 +3336,17 @@ HRESULT CArchiveLink::Open(COpenOptions &op) | |||
3345 | break; | 3336 | break; |
3346 | 3337 | ||
3347 | CArc arc2; | 3338 | CArc arc2; |
3348 | RINOK(arc.GetItem_Path(mainSubfile, arc2.Path)); | 3339 | RINOK(arc.GetItem_Path(mainSubfile, arc2.Path)) |
3349 | 3340 | ||
3350 | bool zerosTailIsAllowed; | 3341 | bool zerosTailIsAllowed; |
3351 | RINOK(Archive_GetItemBoolProp(arc.Archive, mainSubfile, kpidZerosTailIsAllowed, zerosTailIsAllowed)); | 3342 | RINOK(Archive_GetItemBoolProp(arc.Archive, mainSubfile, kpidZerosTailIsAllowed, zerosTailIsAllowed)) |
3352 | 3343 | ||
3353 | 3344 | ||
3354 | if (op.callback) | 3345 | if (op.callback) |
3355 | { | 3346 | { |
3356 | CMyComPtr<IArchiveOpenSetSubArchiveName> setSubArchiveName; | 3347 | Z7_DECL_CMyComPtr_QI_FROM( |
3357 | op.callback->QueryInterface(IID_IArchiveOpenSetSubArchiveName, (void **)&setSubArchiveName); | 3348 | IArchiveOpenSetSubArchiveName, |
3349 | setSubArchiveName, op.callback) | ||
3358 | if (setSubArchiveName) | 3350 | if (setSubArchiveName) |
3359 | setSubArchiveName->SetSubArchiveName(arc2.Path); | 3351 | setSubArchiveName->SetSubArchiveName(arc2.Path); |
3360 | } | 3352 | } |
@@ -3365,7 +3357,7 @@ HRESULT CArchiveLink::Open(COpenOptions &op) | |||
3365 | CIntVector excl; | 3357 | CIntVector excl; |
3366 | 3358 | ||
3367 | COpenOptions op2; | 3359 | COpenOptions op2; |
3368 | #ifndef _SFX | 3360 | #ifndef Z7_SFX |
3369 | op2.props = op.props; | 3361 | op2.props = op.props; |
3370 | #endif | 3362 | #endif |
3371 | op2.codecs = op.codecs; | 3363 | op2.codecs = op.codecs; |
@@ -3388,8 +3380,8 @@ HRESULT CArchiveLink::Open(COpenOptions &op) | |||
3388 | NonOpen_ArcPath = arc2.Path; | 3380 | NonOpen_ArcPath = arc2.Path; |
3389 | break; | 3381 | break; |
3390 | } | 3382 | } |
3391 | RINOK(result); | 3383 | RINOK(result) |
3392 | RINOK(arc.GetItem_MTime(mainSubfile, arc2.MTime)); | 3384 | RINOK(arc.GetItem_MTime(mainSubfile, arc2.MTime)) |
3393 | Arcs.Add(arc2); | 3385 | Arcs.Add(arc2); |
3394 | } | 3386 | } |
3395 | IsOpen = !Arcs.IsEmpty(); | 3387 | IsOpen = !Arcs.IsEmpty(); |
@@ -3408,7 +3400,7 @@ HRESULT CArchiveLink::Open2(COpenOptions &op, IOpenCallbackUI *callbackUI) | |||
3408 | if (!op.stream && !op.stdInMode) | 3400 | if (!op.stream && !op.stdInMode) |
3409 | { | 3401 | { |
3410 | NFile::NDir::GetFullPathAndSplit(us2fs(op.filePath), prefix, name); | 3402 | NFile::NDir::GetFullPathAndSplit(us2fs(op.filePath), prefix, name); |
3411 | RINOK(openCallbackSpec->Init2(prefix, name)); | 3403 | RINOK(openCallbackSpec->Init2(prefix, name)) |
3412 | } | 3404 | } |
3413 | else | 3405 | else |
3414 | { | 3406 | { |
@@ -3423,7 +3415,7 @@ HRESULT CArchiveLink::Open2(COpenOptions &op, IOpenCallbackUI *callbackUI) | |||
3423 | PasswordWasAsked = openCallbackSpec->PasswordWasAsked; | 3415 | PasswordWasAsked = openCallbackSpec->PasswordWasAsked; |
3424 | // Password = openCallbackSpec->Password; | 3416 | // Password = openCallbackSpec->Password; |
3425 | 3417 | ||
3426 | RINOK(res); | 3418 | RINOK(res) |
3427 | // VolumePaths.Add(fs2us(prefix + name)); | 3419 | // VolumePaths.Add(fs2us(prefix + name)); |
3428 | 3420 | ||
3429 | FOR_VECTOR (i, openCallbackSpec->FileNames_WasUsed) | 3421 | FOR_VECTOR (i, openCallbackSpec->FileNames_WasUsed) |
@@ -3446,8 +3438,9 @@ HRESULT CArc::ReOpen(const COpenOptions &op, IArchiveOpenCallback *openCallback_ | |||
3446 | UInt64 fileSize = 0; | 3438 | UInt64 fileSize = 0; |
3447 | if (op.stream) | 3439 | if (op.stream) |
3448 | { | 3440 | { |
3449 | RINOK(op.stream->Seek(0, STREAM_SEEK_END, &fileSize)); | 3441 | RINOK(InStream_SeekToBegin(op.stream)) |
3450 | RINOK(op.stream->Seek(0, STREAM_SEEK_SET, NULL)); | 3442 | RINOK(InStream_AtBegin_GetSize(op.stream, fileSize)) |
3443 | // RINOK(InStream_GetSize_SeekToBegin(op.stream, fileSize)) | ||
3451 | } | 3444 | } |
3452 | FileSize = fileSize; | 3445 | FileSize = fileSize; |
3453 | 3446 | ||
@@ -3462,7 +3455,7 @@ HRESULT CArc::ReOpen(const COpenOptions &op, IArchiveOpenCallback *openCallback_ | |||
3462 | tailStreamSpec->Stream = op.stream; | 3455 | tailStreamSpec->Stream = op.stream; |
3463 | tailStreamSpec->Offset = (UInt64)globalOffset; | 3456 | tailStreamSpec->Offset = (UInt64)globalOffset; |
3464 | tailStreamSpec->Init(); | 3457 | tailStreamSpec->Init(); |
3465 | RINOK(tailStreamSpec->SeekToStart()); | 3458 | RINOK(tailStreamSpec->SeekToStart()) |
3466 | } | 3459 | } |
3467 | 3460 | ||
3468 | // There are archives with embedded STUBs (like ZIP), so we must support signature scanning | 3461 | // There are archives with embedded STUBs (like ZIP), so we must support signature scanning |
@@ -3475,7 +3468,7 @@ HRESULT CArc::ReOpen(const COpenOptions &op, IArchiveOpenCallback *openCallback_ | |||
3475 | 3468 | ||
3476 | if (res == S_OK) | 3469 | if (res == S_OK) |
3477 | { | 3470 | { |
3478 | RINOK(ReadBasicProps(Archive, (UInt64)globalOffset, res)); | 3471 | RINOK(ReadBasicProps(Archive, (UInt64)globalOffset, res)) |
3479 | ArcStreamOffset = (UInt64)globalOffset; | 3472 | ArcStreamOffset = (UInt64)globalOffset; |
3480 | if (ArcStreamOffset != 0) | 3473 | if (ArcStreamOffset != 0) |
3481 | InStream = op.stream; | 3474 | InStream = op.stream; |
@@ -3488,7 +3481,7 @@ HRESULT CArchiveLink::Open3(COpenOptions &op, IOpenCallbackUI *callbackUI) | |||
3488 | HRESULT res = Open2(op, callbackUI); | 3481 | HRESULT res = Open2(op, callbackUI); |
3489 | if (callbackUI) | 3482 | if (callbackUI) |
3490 | { | 3483 | { |
3491 | RINOK(callbackUI->Open_Finished()); | 3484 | RINOK(callbackUI->Open_Finished()) |
3492 | } | 3485 | } |
3493 | return res; | 3486 | return res; |
3494 | } | 3487 | } |
@@ -3508,6 +3501,8 @@ HRESULT CArchiveLink::ReOpen(COpenOptions &op) | |||
3508 | if (Arcs.Size() == 0) // ??? | 3501 | if (Arcs.Size() == 0) // ??? |
3509 | return Open2(op, NULL); | 3502 | return Open2(op, NULL); |
3510 | 3503 | ||
3504 | /* if archive is multivolume (unsupported here still) | ||
3505 | COpenCallbackImp object will exist after Open stage. */ | ||
3511 | COpenCallbackImp *openCallbackSpec = new COpenCallbackImp; | 3506 | COpenCallbackImp *openCallbackSpec = new COpenCallbackImp; |
3512 | CMyComPtr<IArchiveOpenCallback> openCallbackNew = openCallbackSpec; | 3507 | CMyComPtr<IArchiveOpenCallback> openCallbackNew = openCallbackSpec; |
3513 | 3508 | ||
@@ -3516,7 +3511,7 @@ HRESULT CArchiveLink::ReOpen(COpenOptions &op) | |||
3516 | { | 3511 | { |
3517 | FString dirPrefix, fileName; | 3512 | FString dirPrefix, fileName; |
3518 | NFile::NDir::GetFullPathAndSplit(us2fs(op.filePath), dirPrefix, fileName); | 3513 | NFile::NDir::GetFullPathAndSplit(us2fs(op.filePath), dirPrefix, fileName); |
3519 | RINOK(openCallbackSpec->Init2(dirPrefix, fileName)); | 3514 | RINOK(openCallbackSpec->Init2(dirPrefix, fileName)) |
3520 | } | 3515 | } |
3521 | 3516 | ||
3522 | 3517 | ||
@@ -3527,7 +3522,9 @@ HRESULT CArchiveLink::ReOpen(COpenOptions &op) | |||
3527 | op.stream = stream; | 3522 | op.stream = stream; |
3528 | 3523 | ||
3529 | CArc &arc = Arcs[0]; | 3524 | CArc &arc = Arcs[0]; |
3530 | HRESULT res = arc.ReOpen(op, openCallbackNew); | 3525 | const HRESULT res = arc.ReOpen(op, openCallbackNew); |
3526 | |||
3527 | openCallbackSpec->ReOpenCallback = NULL; | ||
3531 | 3528 | ||
3532 | PasswordWasAsked = openCallbackSpec->PasswordWasAsked; | 3529 | PasswordWasAsked = openCallbackSpec->PasswordWasAsked; |
3533 | // Password = openCallbackSpec->Password; | 3530 | // Password = openCallbackSpec->Password; |
@@ -3536,7 +3533,7 @@ HRESULT CArchiveLink::ReOpen(COpenOptions &op) | |||
3536 | return res; | 3533 | return res; |
3537 | } | 3534 | } |
3538 | 3535 | ||
3539 | #ifndef _SFX | 3536 | #ifndef Z7_SFX |
3540 | 3537 | ||
3541 | bool ParseComplexSize(const wchar_t *s, UInt64 &result); | 3538 | bool ParseComplexSize(const wchar_t *s, UInt64 &result); |
3542 | bool ParseComplexSize(const wchar_t *s, UInt64 &result) | 3539 | bool ParseComplexSize(const wchar_t *s, UInt64 &result) |
diff --git a/CPP/7zip/UI/Common/OpenArchive.h b/CPP/7zip/UI/Common/OpenArchive.h index e3220b9..5c3bfe5 100644 --- a/CPP/7zip/UI/Common/OpenArchive.h +++ b/CPP/7zip/UI/Common/OpenArchive.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // OpenArchive.h | 1 | // OpenArchive.h |
2 | 2 | ||
3 | #ifndef __OPEN_ARCHIVE_H | 3 | #ifndef ZIP7_INC_OPEN_ARCHIVE_H |
4 | #define __OPEN_ARCHIVE_H | 4 | #define ZIP7_INC_OPEN_ARCHIVE_H |
5 | 5 | ||
6 | #include "../../../Windows/PropVariant.h" | 6 | #include "../../../Windows/PropVariant.h" |
7 | 7 | ||
@@ -10,7 +10,7 @@ | |||
10 | #include "Property.h" | 10 | #include "Property.h" |
11 | #include "DirItem.h" | 11 | #include "DirItem.h" |
12 | 12 | ||
13 | #ifndef _SFX | 13 | #ifndef Z7_SFX |
14 | 14 | ||
15 | #define SUPPORT_ALT_STREAMS | 15 | #define SUPPORT_ALT_STREAMS |
16 | 16 | ||
@@ -34,7 +34,7 @@ struct COptionalOpenProperties | |||
34 | }; | 34 | }; |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #ifdef _SFX | 37 | #ifdef Z7_SFX |
38 | #define OPEN_PROPS_DECL | 38 | #define OPEN_PROPS_DECL |
39 | #else | 39 | #else |
40 | #define OPEN_PROPS_DECL const CObjectVector<CProperty> *props; | 40 | #define OPEN_PROPS_DECL const CObjectVector<CProperty> *props; |
@@ -243,7 +243,7 @@ struct CReadArcItem | |||
243 | bool MainIsDir; | 243 | bool MainIsDir; |
244 | UInt32 ParentIndex; // use it, if IsAltStream | 244 | UInt32 ParentIndex; // use it, if IsAltStream |
245 | 245 | ||
246 | #ifndef _SFX | 246 | #ifndef Z7_SFX |
247 | bool _use_baseParentFolder_mode; | 247 | bool _use_baseParentFolder_mode; |
248 | int _baseParentFolder; | 248 | int _baseParentFolder; |
249 | #endif | 249 | #endif |
@@ -254,7 +254,7 @@ struct CReadArcItem | |||
254 | WriteToAltStreamIfColon = false; | 254 | WriteToAltStreamIfColon = false; |
255 | #endif | 255 | #endif |
256 | 256 | ||
257 | #ifndef _SFX | 257 | #ifndef Z7_SFX |
258 | _use_baseParentFolder_mode = false; | 258 | _use_baseParentFolder_mode = false; |
259 | _baseParentFolder = -1; | 259 | _baseParentFolder = -1; |
260 | #endif | 260 | #endif |
@@ -270,7 +270,7 @@ class CArc | |||
270 | HRESULT CheckZerosTail(const COpenOptions &op, UInt64 offset); | 270 | HRESULT CheckZerosTail(const COpenOptions &op, UInt64 offset); |
271 | HRESULT OpenStream2(const COpenOptions &options); | 271 | HRESULT OpenStream2(const COpenOptions &options); |
272 | 272 | ||
273 | #ifndef _SFX | 273 | #ifndef Z7_SFX |
274 | // parts.Back() can contain alt stream name "nams:AltName" | 274 | // parts.Back() can contain alt stream name "nams:AltName" |
275 | HRESULT GetItem_PathToParent(UInt32 index, UInt32 parent, UStringVector &parts) const; | 275 | HRESULT GetItem_PathToParent(UInt32 index, UInt32 parent, UStringVector &parts) const; |
276 | #endif | 276 | #endif |
@@ -285,8 +285,17 @@ public: | |||
285 | CMyComPtr<IArchiveGetRawProps> GetRawProps; | 285 | CMyComPtr<IArchiveGetRawProps> GetRawProps; |
286 | CMyComPtr<IArchiveGetRootProps> GetRootProps; | 286 | CMyComPtr<IArchiveGetRootProps> GetRootProps; |
287 | 287 | ||
288 | CArcErrorInfo ErrorInfo; // for OK archives | 288 | bool IsParseArc; |
289 | CArcErrorInfo NonOpen_ErrorInfo; // ErrorInfo for mainArchive (false OPEN) | 289 | |
290 | bool IsTree; | ||
291 | bool IsReadOnly; | ||
292 | |||
293 | bool Ask_Deleted; | ||
294 | bool Ask_AltStream; | ||
295 | bool Ask_Aux; | ||
296 | bool Ask_INode; | ||
297 | |||
298 | bool IgnoreSplit; // don't try split handler | ||
290 | 299 | ||
291 | UString Path; | 300 | UString Path; |
292 | UString filePath; | 301 | UString filePath; |
@@ -305,7 +314,9 @@ public: | |||
305 | // bool OkPhySize_Defined; | 314 | // bool OkPhySize_Defined; |
306 | UInt64 FileSize; | 315 | UInt64 FileSize; |
307 | UInt64 AvailPhySize; // PhySize, but it's reduced if exceed end of file | 316 | UInt64 AvailPhySize; // PhySize, but it's reduced if exceed end of file |
308 | // bool offsetDefined; | 317 | |
318 | CArcErrorInfo ErrorInfo; // for OK archives | ||
319 | CArcErrorInfo NonOpen_ErrorInfo; // ErrorInfo for mainArchive (false OPEN) | ||
309 | 320 | ||
310 | UInt64 GetEstmatedPhySize() const { return PhySize_Defined ? PhySize : FileSize; } | 321 | UInt64 GetEstmatedPhySize() const { return PhySize_Defined ? PhySize : FileSize; } |
311 | 322 | ||
@@ -314,18 +325,6 @@ public: | |||
314 | 325 | ||
315 | // AString ErrorFlagsText; | 326 | // AString ErrorFlagsText; |
316 | 327 | ||
317 | bool IsParseArc; | ||
318 | |||
319 | bool IsTree; | ||
320 | bool IsReadOnly; | ||
321 | |||
322 | bool Ask_Deleted; | ||
323 | bool Ask_AltStream; | ||
324 | bool Ask_Aux; | ||
325 | bool Ask_INode; | ||
326 | |||
327 | bool IgnoreSplit; // don't try split handler | ||
328 | |||
329 | // void Set_ErrorFlagsText(); | 328 | // void Set_ErrorFlagsText(); |
330 | 329 | ||
331 | CArc(): | 330 | CArc(): |
@@ -341,8 +340,6 @@ public: | |||
341 | 340 | ||
342 | HRESULT ReadBasicProps(IInArchive *archive, UInt64 startPos, HRESULT openRes); | 341 | HRESULT ReadBasicProps(IInArchive *archive, UInt64 startPos, HRESULT openRes); |
343 | 342 | ||
344 | // ~CArc(); | ||
345 | |||
346 | HRESULT Close() | 343 | HRESULT Close() |
347 | { | 344 | { |
348 | InStream.Release(); | 345 | InStream.Release(); |
diff --git a/CPP/7zip/UI/Common/PropIDUtils.cpp b/CPP/7zip/UI/Common/PropIDUtils.cpp index 72384b3..ee9ff32 100644 --- a/CPP/7zip/UI/Common/PropIDUtils.cpp +++ b/CPP/7zip/UI/Common/PropIDUtils.cpp | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | #include "PropIDUtils.h" | 15 | #include "PropIDUtils.h" |
16 | 16 | ||
17 | #ifndef _SFX | 17 | #ifndef Z7_SFX |
18 | #define Get16(x) GetUi16(x) | 18 | #define Get16(x) GetUi16(x) |
19 | #define Get32(x) GetUi32(x) | 19 | #define Get32(x) GetUi32(x) |
20 | #endif | 20 | #endif |
@@ -54,7 +54,7 @@ FILE_ATTRIBUTE_ | |||
54 | 54 | ||
55 | 55 | ||
56 | static const char kPosixTypes[16] = { '0', 'p', 'c', '3', 'd', '5', 'b', '7', '-', '9', 'l', 'B', 's', 'D', 'E', 'F' }; | 56 | static const char kPosixTypes[16] = { '0', 'p', 'c', '3', 'd', '5', 'b', '7', '-', '9', 'l', 'B', 's', 'D', 'E', 'F' }; |
57 | #define MY_ATTR_CHAR(a, n, c) ((a) & (1 << (n))) ? c : '-'; | 57 | #define MY_ATTR_CHAR(a, n, c) (((a) & (1 << (n))) ? c : '-') |
58 | 58 | ||
59 | static void ConvertPosixAttribToString(char *s, UInt32 a) throw() | 59 | static void ConvertPosixAttribToString(char *s, UInt32 a) throw() |
60 | { | 60 | { |
@@ -88,7 +88,7 @@ void ConvertWinAttribToString(char *s, UInt32 wa) throw() | |||
88 | info-zip - no additional marker. | 88 | info-zip - no additional marker. |
89 | */ | 89 | */ |
90 | 90 | ||
91 | bool isPosix = ((wa & 0xF0000000) != 0); | 91 | const bool isPosix = ((wa & 0xF0000000) != 0); |
92 | 92 | ||
93 | UInt32 posix = 0; | 93 | UInt32 posix = 0; |
94 | if (isPosix) | 94 | if (isPosix) |
@@ -183,7 +183,7 @@ void ConvertPropertyToShortString2(char *dest, const PROPVARIANT &prop, PROPID p | |||
183 | { | 183 | { |
184 | if (prop.vt != VT_UI4) | 184 | if (prop.vt != VT_UI4) |
185 | break; | 185 | break; |
186 | UInt32 a = prop.ulVal; | 186 | const UInt32 a = prop.ulVal; |
187 | 187 | ||
188 | /* | 188 | /* |
189 | if ((a & 0x8000) && (a & 0x7FFF) == 0) | 189 | if ((a & 0x8000) && (a & 0x7FFF) == 0) |
@@ -207,7 +207,7 @@ void ConvertPropertyToShortString2(char *dest, const PROPVARIANT &prop, PROPID p | |||
207 | ConvertUInt32ToString((UInt32)(prop.uhVal.QuadPart >> 48), dest); | 207 | ConvertUInt32ToString((UInt32)(prop.uhVal.QuadPart >> 48), dest); |
208 | dest += strlen(dest); | 208 | dest += strlen(dest); |
209 | *dest++ = '-'; | 209 | *dest++ = '-'; |
210 | UInt64 low = prop.uhVal.QuadPart & (((UInt64)1 << 48) - 1); | 210 | const UInt64 low = prop.uhVal.QuadPart & (((UInt64)1 << 48) - 1); |
211 | ConvertUInt64ToString(low, dest); | 211 | ConvertUInt64ToString(low, dest); |
212 | return; | 212 | return; |
213 | } | 213 | } |
@@ -260,7 +260,7 @@ void ConvertPropertyToString2(UString &dest, const PROPVARIANT &prop, PROPID pro | |||
260 | dest = temp; | 260 | dest = temp; |
261 | } | 261 | } |
262 | 262 | ||
263 | #ifndef _SFX | 263 | #ifndef Z7_SFX |
264 | 264 | ||
265 | static inline unsigned GetHex(unsigned v) | 265 | static inline unsigned GetHex(unsigned v) |
266 | { | 266 | { |
@@ -387,33 +387,33 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize) | |||
387 | s += "ERROR"; | 387 | s += "ERROR"; |
388 | return; | 388 | return; |
389 | } | 389 | } |
390 | UInt32 rev = p[0]; | 390 | const UInt32 rev = p[0]; |
391 | if (rev != 1) | 391 | if (rev != 1) |
392 | { | 392 | { |
393 | s += "UNSUPPORTED"; | 393 | s += "UNSUPPORTED"; |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | UInt32 num = p[1]; | 396 | const UInt32 num = p[1]; |
397 | if (8 + num * 4 > lim) | 397 | if (8 + num * 4 > lim) |
398 | { | 398 | { |
399 | s += "ERROR"; | 399 | s += "ERROR"; |
400 | return; | 400 | return; |
401 | } | 401 | } |
402 | sidSize = 8 + num * 4; | 402 | sidSize = 8 + num * 4; |
403 | UInt32 authority = GetBe32(p + 4); | 403 | const UInt32 authority = GetBe32(p + 4); |
404 | 404 | ||
405 | if (p[2] == 0 && p[3] == 0 && authority == 5 && num >= 1) | 405 | if (p[2] == 0 && p[3] == 0 && authority == 5 && num >= 1) |
406 | { | 406 | { |
407 | UInt32 v0 = Get32(p + 8); | 407 | const UInt32 v0 = Get32(p + 8); |
408 | if (v0 < ARRAY_SIZE(sidNames)) | 408 | if (v0 < Z7_ARRAY_SIZE(sidNames)) |
409 | { | 409 | { |
410 | s += sidNames[v0]; | 410 | s += sidNames[v0]; |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | if (v0 == 32 && num == 2) | 413 | if (v0 == 32 && num == 2) |
414 | { | 414 | { |
415 | UInt32 v1 = Get32(p + 12); | 415 | const UInt32 v1 = Get32(p + 12); |
416 | int index = FindPairIndex(sid_32_Names, ARRAY_SIZE(sid_32_Names), v1); | 416 | const int index = FindPairIndex(sid_32_Names, Z7_ARRAY_SIZE(sid_32_Names), v1); |
417 | if (index >= 0) | 417 | if (index >= 0) |
418 | { | 418 | { |
419 | s += sid_32_Names[(unsigned)index].sz; | 419 | s += sid_32_Names[(unsigned)index].sz; |
@@ -423,7 +423,7 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize) | |||
423 | if (v0 == 21 && num == 5) | 423 | if (v0 == 21 && num == 5) |
424 | { | 424 | { |
425 | UInt32 v4 = Get32(p + 8 + 4 * 4); | 425 | UInt32 v4 = Get32(p + 8 + 4 * 4); |
426 | int index = FindPairIndex(sid_21_Names, ARRAY_SIZE(sid_21_Names), v4); | 426 | const int index = FindPairIndex(sid_21_Names, Z7_ARRAY_SIZE(sid_21_Names), v4); |
427 | if (index >= 0) | 427 | if (index >= 0) |
428 | { | 428 | { |
429 | s += sid_21_Names[(unsigned)index].sz; | 429 | s += sid_21_Names[(unsigned)index].sz; |
@@ -432,7 +432,7 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize) | |||
432 | } | 432 | } |
433 | if (v0 == 80 && num == 6) | 433 | if (v0 == 80 && num == 6) |
434 | { | 434 | { |
435 | for (unsigned i = 0; i < ARRAY_SIZE(services_to_name); i++) | 435 | for (unsigned i = 0; i < Z7_ARRAY_SIZE(services_to_name); i++) |
436 | { | 436 | { |
437 | const CServicesToName &sn = services_to_name[i]; | 437 | const CServicesToName &sn = services_to_name[i]; |
438 | int j; | 438 | int j; |
@@ -457,7 +457,7 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize) | |||
457 | } | 457 | } |
458 | for (UInt32 i = 0; i < num; i++) | 458 | for (UInt32 i = 0; i < num; i++) |
459 | { | 459 | { |
460 | s += '-'; | 460 | s.Add_Minus(); |
461 | s.Add_UInt32(Get32(p + 8 + i * 4)); | 461 | s.Add_UInt32(Get32(p + 8 + i * 4)); |
462 | } | 462 | } |
463 | } | 463 | } |
@@ -475,10 +475,10 @@ static void ParseOwner(AString &s, const Byte *p, UInt32 size, UInt32 pos) | |||
475 | 475 | ||
476 | static void ParseAcl(AString &s, const Byte *p, UInt32 size, const char *strName, UInt32 flags, UInt32 offset) | 476 | static void ParseAcl(AString &s, const Byte *p, UInt32 size, const char *strName, UInt32 flags, UInt32 offset) |
477 | { | 477 | { |
478 | UInt32 control = Get16(p + 2); | 478 | const UInt32 control = Get16(p + 2); |
479 | if ((flags & control) == 0) | 479 | if ((flags & control) == 0) |
480 | return; | 480 | return; |
481 | UInt32 pos = Get32(p + offset); | 481 | const UInt32 pos = Get32(p + offset); |
482 | s.Add_Space(); | 482 | s.Add_Space(); |
483 | s += strName; | 483 | s += strName; |
484 | if (pos >= size) | 484 | if (pos >= size) |
@@ -489,7 +489,7 @@ static void ParseAcl(AString &s, const Byte *p, UInt32 size, const char *strName | |||
489 | return; | 489 | return; |
490 | if (Get16(p) != 2) // revision | 490 | if (Get16(p) != 2) // revision |
491 | return; | 491 | return; |
492 | UInt32 num = Get32(p + 4); | 492 | const UInt32 num = Get32(p + 4); |
493 | s.Add_UInt32(num); | 493 | s.Add_UInt32(num); |
494 | 494 | ||
495 | /* | 495 | /* |
@@ -580,26 +580,26 @@ static bool CheckSid(const Byte *data, UInt32 size, UInt32 pos) throw() | |||
580 | size -= pos; | 580 | size -= pos; |
581 | if (size < 8) | 581 | if (size < 8) |
582 | return false; | 582 | return false; |
583 | UInt32 rev = data[pos]; | 583 | const UInt32 rev = data[pos]; |
584 | if (rev != 1) | 584 | if (rev != 1) |
585 | return false; | 585 | return false; |
586 | UInt32 num = data[pos + 1]; | 586 | const UInt32 num = data[pos + 1]; |
587 | return (8 + num * 4 <= size); | 587 | return (8 + num * 4 <= size); |
588 | } | 588 | } |
589 | 589 | ||
590 | static bool CheckAcl(const Byte *p, UInt32 size, UInt32 flags, UInt32 offset) throw() | 590 | static bool CheckAcl(const Byte *p, UInt32 size, UInt32 flags, UInt32 offset) throw() |
591 | { | 591 | { |
592 | UInt32 control = Get16(p + 2); | 592 | const UInt32 control = Get16(p + 2); |
593 | if ((flags & control) == 0) | 593 | if ((flags & control) == 0) |
594 | return true; | 594 | return true; |
595 | UInt32 pos = Get32(p + offset); | 595 | const UInt32 pos = Get32(p + offset); |
596 | if (pos >= size) | 596 | if (pos >= size) |
597 | return false; | 597 | return false; |
598 | p += pos; | 598 | p += pos; |
599 | size -= pos; | 599 | size -= pos; |
600 | if (size < 8) | 600 | if (size < 8) |
601 | return false; | 601 | return false; |
602 | UInt32 aclSize = Get16(p + 2); | 602 | const UInt32 aclSize = Get16(p + 2); |
603 | return (aclSize <= size); | 603 | return (aclSize <= size); |
604 | } | 604 | } |
605 | 605 | ||
@@ -686,22 +686,22 @@ bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s) | |||
686 | 686 | ||
687 | if (size < 8) | 687 | if (size < 8) |
688 | return false; | 688 | return false; |
689 | UInt32 tag = Get32(data); | 689 | const UInt32 tag = Get32(data); |
690 | UInt32 len = Get16(data + 4); | 690 | const UInt32 len = Get16(data + 4); |
691 | if (len + 8 > size) | 691 | if (len + 8 > size) |
692 | return false; | 692 | return false; |
693 | if (Get16(data + 6) != 0) // padding | 693 | if (Get16(data + 6) != 0) // padding |
694 | return false; | 694 | return false; |
695 | 695 | ||
696 | /* | 696 | /* |
697 | #define _my_IO_REPARSE_TAG_DEDUP (0x80000013L) | 697 | #define my_IO_REPARSE_TAG_DEDUP (0x80000013L) |
698 | if (tag == _my_IO_REPARSE_TAG_DEDUP) | 698 | if (tag == my_IO_REPARSE_TAG_DEDUP) |
699 | { | 699 | { |
700 | } | 700 | } |
701 | */ | 701 | */ |
702 | 702 | ||
703 | { | 703 | { |
704 | int index = FindPairIndex(k_ReparseTags, ARRAY_SIZE(k_ReparseTags), tag); | 704 | const int index = FindPairIndex(k_ReparseTags, Z7_ARRAY_SIZE(k_ReparseTags), tag); |
705 | if (index >= 0) | 705 | if (index >= 0) |
706 | s += k_ReparseTags[(unsigned)index].sz; | 706 | s += k_ReparseTags[(unsigned)index].sz; |
707 | else | 707 | else |
@@ -729,7 +729,7 @@ bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s) | |||
729 | s += "..."; | 729 | s += "..."; |
730 | break; | 730 | break; |
731 | } | 731 | } |
732 | unsigned b = data[i]; | 732 | const unsigned b = data[i]; |
733 | s += (char)GetHex((b >> 4) & 0xF); | 733 | s += (char)GetHex((b >> 4) & 0xF); |
734 | s += (char)GetHex(b & 0xF); | 734 | s += (char)GetHex(b & 0xF); |
735 | } | 735 | } |
diff --git a/CPP/7zip/UI/Common/PropIDUtils.h b/CPP/7zip/UI/Common/PropIDUtils.h index 915bfc2..6df1e94 100644 --- a/CPP/7zip/UI/Common/PropIDUtils.h +++ b/CPP/7zip/UI/Common/PropIDUtils.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // PropIDUtils.h | 1 | // PropIDUtils.h |
2 | 2 | ||
3 | #ifndef __PROPID_UTILS_H | 3 | #ifndef ZIP7_INC_PROPID_UTILS_H |
4 | #define __PROPID_UTILS_H | 4 | #define ZIP7_INC_PROPID_UTILS_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
@@ -11,7 +11,7 @@ void ConvertPropertyToString2(UString &dest, const PROPVARIANT &propVariant, PRO | |||
11 | 11 | ||
12 | bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s); | 12 | bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s); |
13 | void ConvertNtSecureToString(const Byte *data, UInt32 size, AString &s); | 13 | void ConvertNtSecureToString(const Byte *data, UInt32 size, AString &s); |
14 | bool CheckNtSecure(const Byte *data, UInt32 size) throw();; | 14 | bool CheckNtSecure(const Byte *data, UInt32 size) throw(); |
15 | 15 | ||
16 | void ConvertWinAttribToString(char *s, UInt32 wa) throw(); | 16 | void ConvertWinAttribToString(char *s, UInt32 wa) throw(); |
17 | 17 | ||
diff --git a/CPP/7zip/UI/Common/Property.h b/CPP/7zip/UI/Common/Property.h index 8b57a2a..0462809 100644 --- a/CPP/7zip/UI/Common/Property.h +++ b/CPP/7zip/UI/Common/Property.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // Property.h | 1 | // Property.h |
2 | 2 | ||
3 | #ifndef __7Z_PROPERTY_H | 3 | #ifndef ZIP7_INC_7Z_PROPERTY_H |
4 | #define __7Z_PROPERTY_H | 4 | #define ZIP7_INC_7Z_PROPERTY_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/SetProperties.cpp b/CPP/7zip/UI/Common/SetProperties.cpp index 4b3037a..5e15d9c 100644 --- a/CPP/7zip/UI/Common/SetProperties.cpp +++ b/CPP/7zip/UI/Common/SetProperties.cpp | |||
@@ -18,7 +18,7 @@ using namespace NCOM; | |||
18 | static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop) | 18 | static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop) |
19 | { | 19 | { |
20 | const wchar_t *end; | 20 | const wchar_t *end; |
21 | UInt64 result = ConvertStringToUInt64(s, &end); | 21 | const UInt64 result = ConvertStringToUInt64(s, &end); |
22 | if (*end != 0 || s.IsEmpty()) | 22 | if (*end != 0 || s.IsEmpty()) |
23 | prop = s; | 23 | prop = s; |
24 | else if (result <= (UInt32)0xFFFFFFFF) | 24 | else if (result <= (UInt32)0xFFFFFFFF) |
@@ -46,8 +46,9 @@ HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &propert | |||
46 | { | 46 | { |
47 | if (properties.IsEmpty()) | 47 | if (properties.IsEmpty()) |
48 | return S_OK; | 48 | return S_OK; |
49 | CMyComPtr<ISetProperties> setProperties; | 49 | Z7_DECL_CMyComPtr_QI_FROM( |
50 | unknown->QueryInterface(IID_ISetProperties, (void **)&setProperties); | 50 | ISetProperties, |
51 | setProperties, unknown) | ||
51 | if (!setProperties) | 52 | if (!setProperties) |
52 | return S_OK; | 53 | return S_OK; |
53 | 54 | ||
@@ -64,7 +65,7 @@ HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &propert | |||
64 | { | 65 | { |
65 | if (!name.IsEmpty()) | 66 | if (!name.IsEmpty()) |
66 | { | 67 | { |
67 | wchar_t c = name.Back(); | 68 | const wchar_t c = name.Back(); |
68 | if (c == L'-') | 69 | if (c == L'-') |
69 | propVariant = false; | 70 | propVariant = false; |
70 | else if (c == L'+') | 71 | else if (c == L'+') |
diff --git a/CPP/7zip/UI/Common/SetProperties.h b/CPP/7zip/UI/Common/SetProperties.h index 892f1a2..0676c45 100644 --- a/CPP/7zip/UI/Common/SetProperties.h +++ b/CPP/7zip/UI/Common/SetProperties.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // SetProperties.h | 1 | // SetProperties.h |
2 | 2 | ||
3 | #ifndef __SETPROPERTIES_H | 3 | #ifndef ZIP7_INC_SETPROPERTIES_H |
4 | #define __SETPROPERTIES_H | 4 | #define ZIP7_INC_SETPROPERTIES_H |
5 | 5 | ||
6 | #include "Property.h" | 6 | #include "Property.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/SortUtils.h b/CPP/7zip/UI/Common/SortUtils.h index 8e42e06..07aa24d 100644 --- a/CPP/7zip/UI/Common/SortUtils.h +++ b/CPP/7zip/UI/Common/SortUtils.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // SortUtils.h | 1 | // SortUtils.h |
2 | 2 | ||
3 | #ifndef __SORT_UTLS_H | 3 | #ifndef ZIP7_INC_SORT_UTLS_H |
4 | #define __SORT_UTLS_H | 4 | #define ZIP7_INC_SORT_UTLS_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/StdAfx.h b/CPP/7zip/UI/Common/StdAfx.h index 2854ff3..035267c 100644 --- a/CPP/7zip/UI/Common/StdAfx.h +++ b/CPP/7zip/UI/Common/StdAfx.h | |||
@@ -1,8 +1,11 @@ | |||
1 | // StdAfx.h | 1 | // StdAfx.h |
2 | 2 | ||
3 | #ifndef __STDAFX_H | 3 | #ifndef ZIP7_INC_STDAFX_H |
4 | #define __STDAFX_H | 4 | #define ZIP7_INC_STDAFX_H |
5 | 5 | ||
6 | #if defined(_MSC_VER) && _MSC_VER >= 1800 | ||
7 | #pragma warning(disable : 4464) // relative include path contains '..' | ||
8 | #endif | ||
6 | #include "../../../Common/Common.h" | 9 | #include "../../../Common/Common.h" |
7 | 10 | ||
8 | #endif | 11 | #endif |
diff --git a/CPP/7zip/UI/Common/TempFiles.h b/CPP/7zip/UI/Common/TempFiles.h index 4099e65..dd4ac20 100644 --- a/CPP/7zip/UI/Common/TempFiles.h +++ b/CPP/7zip/UI/Common/TempFiles.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // TempFiles.h | 1 | // TempFiles.h |
2 | 2 | ||
3 | #ifndef __TEMP_FILES_H | 3 | #ifndef ZIP7_INC_TEMP_FILES_H |
4 | #define __TEMP_FILES_H | 4 | #define ZIP7_INC_TEMP_FILES_H |
5 | 5 | ||
6 | #include "../../../Common/MyString.h" | 6 | #include "../../../Common/MyString.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp index 042991d..27625ae 100644 --- a/CPP/7zip/UI/Common/Update.cpp +++ b/CPP/7zip/UI/Common/Update.cpp | |||
@@ -18,6 +18,8 @@ | |||
18 | 18 | ||
19 | #include "../../Common/FileStreams.h" | 19 | #include "../../Common/FileStreams.h" |
20 | #include "../../Common/LimitedStreams.h" | 20 | #include "../../Common/LimitedStreams.h" |
21 | #include "../../Common/MultiOutStream.h" | ||
22 | #include "../../Common/StreamUtils.h" | ||
21 | 23 | ||
22 | #include "../../Compress/CopyCoder.h" | 24 | #include "../../Compress/CopyCoder.h" |
23 | 25 | ||
@@ -71,203 +73,44 @@ HRESULT CUpdateErrorInfo::SetFromError_DWORD(const char *message, const FString | |||
71 | 73 | ||
72 | using namespace NUpdateArchive; | 74 | using namespace NUpdateArchive; |
73 | 75 | ||
74 | class COutMultiVolStream: | 76 | struct CMultiOutStream_Rec |
75 | public IOutStream, | ||
76 | public CMyUnknownImp | ||
77 | { | 77 | { |
78 | unsigned _streamIndex; // required stream | 78 | CMultiOutStream *Spec; |
79 | UInt64 _offsetPos; // offset from start of _streamIndex index | 79 | CMyComPtr<IOutStream> Ref; |
80 | UInt64 _absPos; | ||
81 | UInt64 _length; | ||
82 | |||
83 | struct CAltStreamInfo | ||
84 | { | ||
85 | COutFileStream *StreamSpec; | ||
86 | CMyComPtr<IOutStream> Stream; | ||
87 | FString Name; | ||
88 | UInt64 Pos; | ||
89 | UInt64 RealSize; | ||
90 | }; | ||
91 | CObjectVector<CAltStreamInfo> Streams; | ||
92 | public: | ||
93 | // CMyComPtr<IArchiveUpdateCallback2> VolumeCallback; | ||
94 | CRecordVector<UInt64> Sizes; | ||
95 | FString Prefix; | ||
96 | CTempFiles *TempFiles; | ||
97 | |||
98 | void Init() | ||
99 | { | ||
100 | _streamIndex = 0; | ||
101 | _offsetPos = 0; | ||
102 | _absPos = 0; | ||
103 | _length = 0; | ||
104 | } | ||
105 | |||
106 | bool SetMTime(const CFiTime *mTime); | ||
107 | HRESULT Close(); | ||
108 | |||
109 | UInt64 GetSize() const { return _length; } | ||
110 | |||
111 | MY_UNKNOWN_IMP1(IOutStream) | ||
112 | |||
113 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | ||
114 | STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); | ||
115 | STDMETHOD(SetSize)(UInt64 newSize); | ||
116 | }; | 80 | }; |
117 | 81 | ||
118 | // static NSynchronization::CCriticalSection g_TempPathsCS; | 82 | struct CMultiOutStream_Bunch |
119 | |||
120 | HRESULT COutMultiVolStream::Close() | ||
121 | { | ||
122 | HRESULT res = S_OK; | ||
123 | FOR_VECTOR (i, Streams) | ||
124 | { | ||
125 | COutFileStream *s = Streams[i].StreamSpec; | ||
126 | if (s) | ||
127 | { | ||
128 | HRESULT res2 = s->Close(); | ||
129 | if (res2 != S_OK) | ||
130 | res = res2; | ||
131 | } | ||
132 | } | ||
133 | return res; | ||
134 | } | ||
135 | |||
136 | bool COutMultiVolStream::SetMTime(const CFiTime *mTime) | ||
137 | { | ||
138 | bool res = true; | ||
139 | FOR_VECTOR (i, Streams) | ||
140 | { | ||
141 | COutFileStream *s = Streams[i].StreamSpec; | ||
142 | if (s) | ||
143 | if (!s->SetMTime(mTime)) | ||
144 | res = false; | ||
145 | } | ||
146 | return res; | ||
147 | } | ||
148 | |||
149 | STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *processedSize) | ||
150 | { | 83 | { |
151 | if (processedSize) | 84 | CObjectVector<CMultiOutStream_Rec> Items; |
152 | *processedSize = 0; | 85 | |
153 | while (size > 0) | 86 | HRESULT Destruct() |
154 | { | 87 | { |
155 | if (_streamIndex >= Streams.Size()) | 88 | HRESULT hres = S_OK; |
89 | FOR_VECTOR (i, Items) | ||
156 | { | 90 | { |
157 | CAltStreamInfo altStream; | 91 | CMultiOutStream_Rec &rec = Items[i]; |
158 | 92 | if (rec.Ref) | |
159 | FString name; | ||
160 | name.Add_UInt32(_streamIndex + 1); | ||
161 | while (name.Len() < 3) | ||
162 | name.InsertAtFront(FTEXT('0')); | ||
163 | name.Insert(0, Prefix); | ||
164 | altStream.StreamSpec = new COutFileStream; | ||
165 | altStream.Stream = altStream.StreamSpec; | ||
166 | if (!altStream.StreamSpec->Create(name, false)) | ||
167 | return GetLastError_noZero_HRESULT(); | ||
168 | { | 93 | { |
169 | // NSynchronization::CCriticalSectionLock lock(g_TempPathsCS); | 94 | const HRESULT hres2 = rec.Spec->Destruct(); |
170 | TempFiles->Paths.Add(name); | 95 | if (hres == S_OK) |
96 | hres = hres2; | ||
171 | } | 97 | } |
172 | |||
173 | altStream.Pos = 0; | ||
174 | altStream.RealSize = 0; | ||
175 | altStream.Name = name; | ||
176 | Streams.Add(altStream); | ||
177 | continue; | ||
178 | } | ||
179 | CAltStreamInfo &altStream = Streams[_streamIndex]; | ||
180 | |||
181 | unsigned index = _streamIndex; | ||
182 | if (index >= Sizes.Size()) | ||
183 | index = Sizes.Size() - 1; | ||
184 | UInt64 volSize = Sizes[index]; | ||
185 | |||
186 | if (_offsetPos >= volSize) | ||
187 | { | ||
188 | _offsetPos -= volSize; | ||
189 | _streamIndex++; | ||
190 | continue; | ||
191 | } | ||
192 | if (_offsetPos != altStream.Pos) | ||
193 | { | ||
194 | // CMyComPtr<IOutStream> outStream; | ||
195 | // RINOK(altStream.Stream.QueryInterface(IID_IOutStream, &outStream)); | ||
196 | RINOK(altStream.Stream->Seek((Int64)_offsetPos, STREAM_SEEK_SET, NULL)); | ||
197 | altStream.Pos = _offsetPos; | ||
198 | } | 98 | } |
199 | 99 | Items.Clear(); | |
200 | UInt32 curSize = (UInt32)MyMin((UInt64)size, volSize - altStream.Pos); | 100 | return hres; |
201 | UInt32 realProcessed; | ||
202 | RINOK(altStream.Stream->Write(data, curSize, &realProcessed)); | ||
203 | data = (const void *)((const Byte *)data + realProcessed); | ||
204 | size -= realProcessed; | ||
205 | altStream.Pos += realProcessed; | ||
206 | _offsetPos += realProcessed; | ||
207 | _absPos += realProcessed; | ||
208 | if (_absPos > _length) | ||
209 | _length = _absPos; | ||
210 | if (_offsetPos > altStream.RealSize) | ||
211 | altStream.RealSize = _offsetPos; | ||
212 | if (processedSize) | ||
213 | *processedSize += realProcessed; | ||
214 | if (altStream.Pos == volSize) | ||
215 | { | ||
216 | _streamIndex++; | ||
217 | _offsetPos = 0; | ||
218 | } | ||
219 | if (realProcessed == 0 && curSize != 0) | ||
220 | return E_FAIL; | ||
221 | break; | ||
222 | } | ||
223 | return S_OK; | ||
224 | } | ||
225 | |||
226 | STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) | ||
227 | { | ||
228 | if (seekOrigin >= 3) | ||
229 | return STG_E_INVALIDFUNCTION; | ||
230 | switch (seekOrigin) | ||
231 | { | ||
232 | case STREAM_SEEK_SET: _absPos = (UInt64)offset; break; | ||
233 | case STREAM_SEEK_CUR: _absPos = (UInt64)((Int64)_absPos + offset); break; | ||
234 | case STREAM_SEEK_END: _absPos = (UInt64)((Int64)_length + offset); break; | ||
235 | } | 101 | } |
236 | _offsetPos = _absPos; | ||
237 | if (newPosition) | ||
238 | *newPosition = _absPos; | ||
239 | _streamIndex = 0; | ||
240 | return S_OK; | ||
241 | } | ||
242 | 102 | ||
243 | STDMETHODIMP COutMultiVolStream::SetSize(UInt64 newSize) | 103 | void DisableDeletion() |
244 | { | ||
245 | unsigned i = 0; | ||
246 | while (i < Streams.Size()) | ||
247 | { | 104 | { |
248 | CAltStreamInfo &altStream = Streams[i++]; | 105 | FOR_VECTOR (i, Items) |
249 | if ((UInt64)newSize < altStream.RealSize) | ||
250 | { | 106 | { |
251 | RINOK(altStream.Stream->SetSize(newSize)); | 107 | CMultiOutStream_Rec &rec = Items[i]; |
252 | altStream.RealSize = newSize; | 108 | if (rec.Ref) |
253 | break; | 109 | rec.Spec->NeedDelete = false; |
254 | } | 110 | } |
255 | newSize -= altStream.RealSize; | ||
256 | } | 111 | } |
257 | while (i < Streams.Size()) | 112 | }; |
258 | { | 113 | |
259 | { | ||
260 | CAltStreamInfo &altStream = Streams.Back(); | ||
261 | altStream.Stream.Release(); | ||
262 | DeleteFileAlways(altStream.Name); | ||
263 | } | ||
264 | Streams.DeleteBack(); | ||
265 | } | ||
266 | _offsetPos = _absPos; | ||
267 | _streamIndex = 0; | ||
268 | _length = newSize; | ||
269 | return S_OK; | ||
270 | } | ||
271 | 114 | ||
272 | void CArchivePath::ParseFromPath(const UString &path, EArcNameMode mode) | 115 | void CArchivePath::ParseFromPath(const UString &path, EArcNameMode mode) |
273 | { | 116 | { |
@@ -305,7 +148,7 @@ UString CArchivePath::GetFinalPath() const | |||
305 | UString path = GetPathWithoutExt(); | 148 | UString path = GetPathWithoutExt(); |
306 | if (!BaseExtension.IsEmpty()) | 149 | if (!BaseExtension.IsEmpty()) |
307 | { | 150 | { |
308 | path += '.'; | 151 | path.Add_Dot(); |
309 | path += BaseExtension; | 152 | path += BaseExtension; |
310 | } | 153 | } |
311 | return path; | 154 | return path; |
@@ -317,7 +160,7 @@ UString CArchivePath::GetFinalVolPath() const | |||
317 | // if BaseExtension is empty, we must ignore VolExtension also. | 160 | // if BaseExtension is empty, we must ignore VolExtension also. |
318 | if (!BaseExtension.IsEmpty()) | 161 | if (!BaseExtension.IsEmpty()) |
319 | { | 162 | { |
320 | path += '.'; | 163 | path.Add_Dot(); |
321 | path += VolExtension; | 164 | path += VolExtension; |
322 | } | 165 | } |
323 | return path; | 166 | return path; |
@@ -329,7 +172,7 @@ FString CArchivePath::GetTempPath() const | |||
329 | path += us2fs(Name); | 172 | path += us2fs(Name); |
330 | if (!BaseExtension.IsEmpty()) | 173 | if (!BaseExtension.IsEmpty()) |
331 | { | 174 | { |
332 | path += '.'; | 175 | path.Add_Dot(); |
333 | path += us2fs(BaseExtension); | 176 | path += us2fs(BaseExtension); |
334 | } | 177 | } |
335 | path += ".tmp"; | 178 | path += ".tmp"; |
@@ -403,7 +246,7 @@ bool CUpdateOptions::SetArcPath(const CCodecs *codecs, const UString &arcPath) | |||
403 | } | 246 | } |
404 | 247 | ||
405 | 248 | ||
406 | struct CUpdateProduceCallbackImp: public IUpdateProduceCallback | 249 | struct CUpdateProduceCallbackImp Z7_final: public IUpdateProduceCallback |
407 | { | 250 | { |
408 | const CObjectVector<CArcItem> *_arcItems; | 251 | const CObjectVector<CArcItem> *_arcItems; |
409 | CDirItemsStat *_stat; | 252 | CDirItemsStat *_stat; |
@@ -417,7 +260,7 @@ struct CUpdateProduceCallbackImp: public IUpdateProduceCallback | |||
417 | _stat(stat), | 260 | _stat(stat), |
418 | _callback(callback) {} | 261 | _callback(callback) {} |
419 | 262 | ||
420 | virtual HRESULT ShowDeleteFile(unsigned arcIndex); | 263 | virtual HRESULT ShowDeleteFile(unsigned arcIndex) Z7_override; |
421 | }; | 264 | }; |
422 | 265 | ||
423 | 266 | ||
@@ -499,6 +342,8 @@ bool CRenamePair::GetNewPath(bool isFolder, const UString &src, UString &dest) c | |||
499 | int FindAltStreamColon_in_Path(const wchar_t *path); | 342 | int FindAltStreamColon_in_Path(const wchar_t *path); |
500 | #endif | 343 | #endif |
501 | 344 | ||
345 | |||
346 | |||
502 | static HRESULT Compress( | 347 | static HRESULT Compress( |
503 | const CUpdateOptions &options, | 348 | const CUpdateOptions &options, |
504 | bool isUpdatingItself, | 349 | bool isUpdatingItself, |
@@ -511,6 +356,7 @@ static HRESULT Compress( | |||
511 | const CDirItems &dirItems, | 356 | const CDirItems &dirItems, |
512 | const CDirItem *parentDirItem, | 357 | const CDirItem *parentDirItem, |
513 | CTempFiles &tempFiles, | 358 | CTempFiles &tempFiles, |
359 | CMultiOutStream_Bunch &multiStreams, | ||
514 | CUpdateErrorInfo &errorInfo, | 360 | CUpdateErrorInfo &errorInfo, |
515 | IUpdateCallbackUI *callback, | 361 | IUpdateCallbackUI *callback, |
516 | CFinishArchiveStat &st) | 362 | CFinishArchiveStat &st) |
@@ -530,15 +376,15 @@ static HRESULT Compress( | |||
530 | } | 376 | } |
531 | else | 377 | else |
532 | { | 378 | { |
533 | RINOK(codecs->CreateOutArchive((unsigned)formatIndex, outArchive)); | 379 | RINOK(codecs->CreateOutArchive((unsigned)formatIndex, outArchive)) |
534 | 380 | ||
535 | #ifdef EXTERNAL_CODECS | 381 | #ifdef Z7_EXTERNAL_CODECS |
536 | { | 382 | { |
537 | CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo; | 383 | CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo; |
538 | outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo); | 384 | outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo); |
539 | if (setCompressCodecsInfo) | 385 | if (setCompressCodecsInfo) |
540 | { | 386 | { |
541 | RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs)); | 387 | RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs)) |
542 | } | 388 | } |
543 | } | 389 | } |
544 | #endif | 390 | #endif |
@@ -548,7 +394,7 @@ static HRESULT Compress( | |||
548 | throw kUpdateIsNotSupoorted; | 394 | throw kUpdateIsNotSupoorted; |
549 | 395 | ||
550 | // we need to set properties to get fileTimeType. | 396 | // we need to set properties to get fileTimeType. |
551 | RINOK(SetProperties(outArchive, options.MethodMode.Properties)); | 397 | RINOK(SetProperties(outArchive, options.MethodMode.Properties)) |
552 | 398 | ||
553 | NFileTimeType::EEnum fileTimeType; | 399 | NFileTimeType::EEnum fileTimeType; |
554 | { | 400 | { |
@@ -580,7 +426,7 @@ static HRESULT Compress( | |||
580 | */ | 426 | */ |
581 | 427 | ||
582 | UInt32 value; | 428 | UInt32 value; |
583 | RINOK(outArchive->GetFileTimeType(&value)); | 429 | RINOK(outArchive->GetFileTimeType(&value)) |
584 | 430 | ||
585 | // we support any future fileType here. | 431 | // we support any future fileType here. |
586 | fileTimeType = (NFileTimeType::EEnum)value; | 432 | fileTimeType = (NFileTimeType::EEnum)value; |
@@ -676,7 +522,7 @@ static HRESULT Compress( | |||
676 | if (needRename) | 522 | if (needRename) |
677 | { | 523 | { |
678 | up2.NewProps = true; | 524 | up2.NewProps = true; |
679 | RINOK(arc->IsItem_Anti(i, up2.IsAnti)); | 525 | RINOK(arc->IsItem_Anti(i, up2.IsAnti)) |
680 | up2.NewNameIndex = (int)newNames.Add(dest); | 526 | up2.NewNameIndex = (int)newNames.Add(dest); |
681 | } | 527 | } |
682 | updatePairs2.Add(up2); | 528 | updatePairs2.Add(up2); |
@@ -768,7 +614,7 @@ static HRESULT Compress( | |||
768 | } | 614 | } |
769 | } | 615 | } |
770 | } | 616 | } |
771 | RINOK(callback->SetNumItems(stat2)); | 617 | RINOK(callback->SetNumItems(stat2)) |
772 | } | 618 | } |
773 | 619 | ||
774 | CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback; | 620 | CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback; |
@@ -828,7 +674,7 @@ static HRESULT Compress( | |||
828 | 674 | ||
829 | COutFileStream *outStreamSpec = NULL; | 675 | COutFileStream *outStreamSpec = NULL; |
830 | CStdOutFileStream *stdOutFileStreamSpec = NULL; | 676 | CStdOutFileStream *stdOutFileStreamSpec = NULL; |
831 | COutMultiVolStream *volStreamSpec = NULL; | 677 | CMultiOutStream *volStreamSpec = NULL; |
832 | 678 | ||
833 | if (options.VolumesSizes.Size() == 0) | 679 | if (options.VolumesSizes.Size() == 0) |
834 | { | 680 | { |
@@ -881,14 +727,17 @@ static HRESULT Compress( | |||
881 | if (arc && arc->GetGlobalOffset() > 0) | 727 | if (arc && arc->GetGlobalOffset() > 0) |
882 | return E_NOTIMPL; | 728 | return E_NOTIMPL; |
883 | 729 | ||
884 | volStreamSpec = new COutMultiVolStream; | 730 | volStreamSpec = new CMultiOutStream(); |
885 | outSeekStream = volStreamSpec; | 731 | outSeekStream = volStreamSpec; |
886 | outStream = outSeekStream; | 732 | outStream = outSeekStream; |
887 | volStreamSpec->Sizes = options.VolumesSizes; | ||
888 | volStreamSpec->Prefix = us2fs(archivePath.GetFinalVolPath()); | 733 | volStreamSpec->Prefix = us2fs(archivePath.GetFinalVolPath()); |
889 | volStreamSpec->Prefix += '.'; | 734 | volStreamSpec->Prefix.Add_Dot(); |
890 | volStreamSpec->TempFiles = &tempFiles; | 735 | volStreamSpec->Init(options.VolumesSizes); |
891 | volStreamSpec->Init(); | 736 | { |
737 | CMultiOutStream_Rec &rec = multiStreams.Items.AddNew(); | ||
738 | rec.Spec = volStreamSpec; | ||
739 | rec.Ref = rec.Spec; | ||
740 | } | ||
892 | 741 | ||
893 | /* | 742 | /* |
894 | updateCallbackSpec->VolumesSizes = volumesSizes; | 743 | updateCallbackSpec->VolumesSizes = volumesSizes; |
@@ -913,22 +762,22 @@ static HRESULT Compress( | |||
913 | { | 762 | { |
914 | outStreamSpec2 = new COutFileStream; | 763 | outStreamSpec2 = new COutFileStream; |
915 | sfxOutStream = outStreamSpec2; | 764 | sfxOutStream = outStreamSpec2; |
916 | FString realPath = us2fs(archivePath.GetFinalPath()); | 765 | const FString realPath = us2fs(archivePath.GetFinalPath()); |
917 | if (!outStreamSpec2->Create(realPath, false)) | 766 | if (!outStreamSpec2->Create(realPath, false)) |
918 | return errorInfo.SetFromLastError("cannot open file", realPath); | 767 | return errorInfo.SetFromLastError("cannot open file", realPath); |
919 | } | 768 | } |
920 | 769 | ||
921 | { | 770 | { |
922 | UInt64 sfxSize; | 771 | UInt64 sfxSize; |
923 | RINOK(sfxStreamSpec->GetSize(&sfxSize)); | 772 | RINOK(sfxStreamSpec->GetSize(&sfxSize)) |
924 | RINOK(callback->WriteSfx(fs2us(options.SfxModule), sfxSize)); | 773 | RINOK(callback->WriteSfx(fs2us(options.SfxModule), sfxSize)) |
925 | } | 774 | } |
926 | 775 | ||
927 | RINOK(NCompress::CopyStream(sfxStream, sfxOutStream, NULL)); | 776 | RINOK(NCompress::CopyStream(sfxStream, sfxOutStream, NULL)) |
928 | 777 | ||
929 | if (outStreamSpec2) | 778 | if (outStreamSpec2) |
930 | { | 779 | { |
931 | RINOK(outStreamSpec2->Close()); | 780 | RINOK(outStreamSpec2->Close()) |
932 | } | 781 | } |
933 | } | 782 | } |
934 | 783 | ||
@@ -939,8 +788,8 @@ static HRESULT Compress( | |||
939 | else | 788 | else |
940 | { | 789 | { |
941 | // Int64 globalOffset = arc->GetGlobalOffset(); | 790 | // Int64 globalOffset = arc->GetGlobalOffset(); |
942 | RINOK(arc->InStream->Seek(0, STREAM_SEEK_SET, NULL)); | 791 | RINOK(InStream_SeekToBegin(arc->InStream)) |
943 | RINOK(NCompress::CopyStream_ExactSize(arc->InStream, outStream, arc->ArcStreamOffset, NULL)); | 792 | RINOK(NCompress::CopyStream_ExactSize(arc->InStream, outStream, arc->ArcStreamOffset, NULL)) |
944 | if (options.StdOutMode) | 793 | if (options.StdOutMode) |
945 | tailStream = outStream; | 794 | tailStream = outStream; |
946 | else | 795 | else |
@@ -953,10 +802,57 @@ static HRESULT Compress( | |||
953 | } | 802 | } |
954 | } | 803 | } |
955 | 804 | ||
805 | CFiTime ft; | ||
806 | FiTime_Clear(ft); | ||
807 | bool ft_Defined = false; | ||
808 | { | ||
809 | FOR_VECTOR (i, updatePairs2) | ||
810 | { | ||
811 | const CUpdatePair2 &pair2 = updatePairs2[i]; | ||
812 | CFiTime ft2; | ||
813 | FiTime_Clear(ft2); | ||
814 | bool ft2_Defined = false; | ||
815 | /* we use full precision of dirItem, if dirItem is defined | ||
816 | and (dirItem will be used or dirItem is sameTime in dir and arc */ | ||
817 | if (pair2.DirIndex >= 0 && | ||
818 | (pair2.NewProps || pair2.IsSameTime)) | ||
819 | { | ||
820 | ft2 = dirItems.Items[(unsigned)pair2.DirIndex].MTime; | ||
821 | ft2_Defined = true; | ||
822 | } | ||
823 | else if (pair2.UseArcProps && pair2.ArcIndex >= 0) | ||
824 | { | ||
825 | const CArcItem &arcItem = arcItems[(unsigned)pair2.ArcIndex]; | ||
826 | if (arcItem.MTime.Def) | ||
827 | { | ||
828 | arcItem.MTime.Write_To_FiTime(ft2); | ||
829 | ft2_Defined = true; | ||
830 | } | ||
831 | } | ||
832 | if (ft2_Defined) | ||
833 | { | ||
834 | if (!ft_Defined || Compare_FiTime(&ft, &ft2) < 0) | ||
835 | { | ||
836 | ft = ft2; | ||
837 | ft_Defined = true; | ||
838 | } | ||
839 | } | ||
840 | } | ||
841 | /* | ||
842 | if (fileTimeType != NFileTimeType::kNotDefined) | ||
843 | FiTime_Normalize_With_Prec(ft, fileTimeType); | ||
844 | */ | ||
845 | } | ||
846 | |||
847 | if (volStreamSpec && options.SetArcMTime && ft_Defined) | ||
848 | { | ||
849 | volStreamSpec->MTime = ft; | ||
850 | volStreamSpec->MTime_Defined = true; | ||
851 | } | ||
956 | 852 | ||
957 | HRESULT result = outArchive->UpdateItems(tailStream, updatePairs2.Size(), updateCallback); | 853 | HRESULT result = outArchive->UpdateItems(tailStream, updatePairs2.Size(), updateCallback); |
958 | // callback->Finalize(); | 854 | // callback->Finalize(); |
959 | RINOK(result); | 855 | RINOK(result) |
960 | 856 | ||
961 | if (!updateCallbackSpec->AreAllFilesClosed()) | 857 | if (!updateCallbackSpec->AreAllFilesClosed()) |
962 | { | 858 | { |
@@ -967,10 +863,6 @@ static HRESULT Compress( | |||
967 | 863 | ||
968 | if (options.SetArcMTime) | 864 | if (options.SetArcMTime) |
969 | { | 865 | { |
970 | CFiTime ft; | ||
971 | FiTime_Clear(ft); | ||
972 | bool isDefined = false; | ||
973 | |||
974 | // bool needNormalizeAfterStream; | 866 | // bool needNormalizeAfterStream; |
975 | // needParse; | 867 | // needParse; |
976 | /* | 868 | /* |
@@ -990,40 +882,9 @@ static HRESULT Compress( | |||
990 | // CArcTime at = StreamCallback_ArcMTime; | 882 | // CArcTime at = StreamCallback_ArcMTime; |
991 | // updateCallbackSpec->StreamCallback_ArcMTime.Write_To_FiTime(ft); | 883 | // updateCallbackSpec->StreamCallback_ArcMTime.Write_To_FiTime(ft); |
992 | // we must normalize with precision from archive; | 884 | // we must normalize with precision from archive; |
993 | ft = updateCallbackSpec->LatestMTime; | 885 | if (!ft_Defined || Compare_FiTime(&ft, &updateCallbackSpec->LatestMTime) < 0) |
994 | isDefined = true; | 886 | ft = updateCallbackSpec->LatestMTime; |
995 | } | 887 | ft_Defined = true; |
996 | |||
997 | FOR_VECTOR (i, updatePairs2) | ||
998 | { | ||
999 | const CUpdatePair2 &pair2 = updatePairs2[i]; | ||
1000 | CFiTime ft2; | ||
1001 | bool ft2_Defined = false; | ||
1002 | /* we use full precision of dirItem, if dirItem is defined | ||
1003 | and (dirItem will be used or dirItem is sameTime in dir and arc */ | ||
1004 | if (pair2.DirIndex >= 0 && | ||
1005 | (pair2.NewProps || pair2.IsSameTime)) | ||
1006 | { | ||
1007 | ft2 = dirItems.Items[(unsigned)pair2.DirIndex].MTime; | ||
1008 | ft2_Defined = true; | ||
1009 | } | ||
1010 | else if (pair2.UseArcProps && pair2.ArcIndex >= 0) | ||
1011 | { | ||
1012 | const CArcItem &arcItem = arcItems[(unsigned)pair2.ArcIndex]; | ||
1013 | if (arcItem.MTime.Def) | ||
1014 | { | ||
1015 | arcItem.MTime.Write_To_FiTime(ft2); | ||
1016 | ft2_Defined = true; | ||
1017 | } | ||
1018 | } | ||
1019 | if (ft2_Defined) | ||
1020 | { | ||
1021 | if (Compare_FiTime(&ft, &ft2) < 0) | ||
1022 | { | ||
1023 | ft = ft2; | ||
1024 | isDefined = true; | ||
1025 | } | ||
1026 | } | ||
1027 | } | 888 | } |
1028 | /* | 889 | /* |
1029 | if (fileTimeType != NFileTimeType::kNotDefined) | 890 | if (fileTimeType != NFileTimeType::kNotDefined) |
@@ -1031,12 +892,14 @@ static HRESULT Compress( | |||
1031 | */ | 892 | */ |
1032 | } | 893 | } |
1033 | // if (ft.dwLowDateTime != 0 || ft.dwHighDateTime != 0) | 894 | // if (ft.dwLowDateTime != 0 || ft.dwHighDateTime != 0) |
1034 | if (isDefined) | 895 | if (ft_Defined) |
1035 | { | 896 | { |
897 | // we ignore set time errors here. | ||
898 | // note that user could move some finished volumes to another folder. | ||
1036 | if (outStreamSpec) | 899 | if (outStreamSpec) |
1037 | outStreamSpec->SetMTime(&ft); | 900 | outStreamSpec->SetMTime(&ft); |
1038 | else if (volStreamSpec) | 901 | else if (volStreamSpec) |
1039 | volStreamSpec->SetMTime(&ft); | 902 | volStreamSpec->SetMTime_Final(ft); |
1040 | } | 903 | } |
1041 | } | 904 | } |
1042 | 905 | ||
@@ -1056,7 +919,10 @@ static HRESULT Compress( | |||
1056 | if (outStreamSpec) | 919 | if (outStreamSpec) |
1057 | result = outStreamSpec->Close(); | 920 | result = outStreamSpec->Close(); |
1058 | else if (volStreamSpec) | 921 | else if (volStreamSpec) |
1059 | result = volStreamSpec->Close(); | 922 | { |
923 | result = volStreamSpec->FinalFlush_and_CloseFiles(st.NumVolumes); | ||
924 | st.IsMultiVolMode = true; | ||
925 | } | ||
1060 | 926 | ||
1061 | RINOK(result) | 927 | RINOK(result) |
1062 | 928 | ||
@@ -1121,7 +987,7 @@ static HRESULT EnumerateInArchiveItems( | |||
1121 | arcItems.Clear(); | 987 | arcItems.Clear(); |
1122 | UInt32 numItems; | 988 | UInt32 numItems; |
1123 | IInArchive *archive = arc.Archive; | 989 | IInArchive *archive = arc.Archive; |
1124 | RINOK(archive->GetNumberOfItems(&numItems)); | 990 | RINOK(archive->GetNumberOfItems(&numItems)) |
1125 | arcItems.ClearAndReserve(numItems); | 991 | arcItems.ClearAndReserve(numItems); |
1126 | 992 | ||
1127 | CReadArcItem item; | 993 | CReadArcItem item; |
@@ -1132,7 +998,7 @@ static HRESULT EnumerateInArchiveItems( | |||
1132 | { | 998 | { |
1133 | CArcItem ai; | 999 | CArcItem ai; |
1134 | 1000 | ||
1135 | RINOK(arc.GetItem(i, item)); | 1001 | RINOK(arc.GetItem(i, item)) |
1136 | ai.Name = item.Path; | 1002 | ai.Name = item.Path; |
1137 | ai.IsDir = item.IsDir; | 1003 | ai.IsDir = item.IsDir; |
1138 | ai.IsAltStream = | 1004 | ai.IsAltStream = |
@@ -1152,8 +1018,8 @@ static HRESULT EnumerateInArchiveItems( | |||
1152 | ai.Censored = Censor_CheckPath(censor, item); | 1018 | ai.Censored = Censor_CheckPath(censor, item); |
1153 | 1019 | ||
1154 | // ai.MTime will be set to archive MTime, if not present in archive item | 1020 | // ai.MTime will be set to archive MTime, if not present in archive item |
1155 | RINOK(arc.GetItem_MTime(i, ai.MTime)); | 1021 | RINOK(arc.GetItem_MTime(i, ai.MTime)) |
1156 | RINOK(arc.GetItem_Size(i, ai.Size, ai.Size_Defined)); | 1022 | RINOK(arc.GetItem_Size(i, ai.Size, ai.Size_Defined)) |
1157 | 1023 | ||
1158 | ai.IndexInServer = i; | 1024 | ai.IndexInServer = i; |
1159 | arcItems.AddInReserved(ai); | 1025 | arcItems.AddInReserved(ai); |
@@ -1163,10 +1029,73 @@ static HRESULT EnumerateInArchiveItems( | |||
1163 | 1029 | ||
1164 | #if defined(_WIN32) && !defined(UNDER_CE) | 1030 | #if defined(_WIN32) && !defined(UNDER_CE) |
1165 | 1031 | ||
1032 | #if defined(__MINGW32__) || defined(__MINGW64__) | ||
1033 | #include <mapi.h> | ||
1034 | #else | ||
1166 | #include <MAPI.h> | 1035 | #include <MAPI.h> |
1167 | |||
1168 | #endif | 1036 | #endif |
1169 | 1037 | ||
1038 | extern "C" { | ||
1039 | |||
1040 | #ifdef MAPI_FORCE_UNICODE | ||
1041 | |||
1042 | #define Z7_WIN_LPMAPISENDMAILW LPMAPISENDMAILW | ||
1043 | #define Z7_WIN_MapiFileDescW MapiFileDescW | ||
1044 | #define Z7_WIN_MapiMessageW MapiMessageW | ||
1045 | #define Z7_WIN_MapiRecipDescW MapiRecipDescW | ||
1046 | |||
1047 | #else | ||
1048 | |||
1049 | typedef struct | ||
1050 | { | ||
1051 | ULONG ulReserved; | ||
1052 | ULONG ulRecipClass; | ||
1053 | PWSTR lpszName; | ||
1054 | PWSTR lpszAddress; | ||
1055 | ULONG ulEIDSize; | ||
1056 | PVOID lpEntryID; | ||
1057 | } Z7_WIN_MapiRecipDescW, *Z7_WIN_lpMapiRecipDescW; | ||
1058 | |||
1059 | typedef struct | ||
1060 | { | ||
1061 | ULONG ulReserved; | ||
1062 | ULONG flFlags; | ||
1063 | ULONG nPosition; | ||
1064 | PWSTR lpszPathName; | ||
1065 | PWSTR lpszFileName; | ||
1066 | PVOID lpFileType; | ||
1067 | } Z7_WIN_MapiFileDescW, *Z7_WIN_lpMapiFileDescW; | ||
1068 | |||
1069 | typedef struct | ||
1070 | { | ||
1071 | ULONG ulReserved; | ||
1072 | PWSTR lpszSubject; | ||
1073 | PWSTR lpszNoteText; | ||
1074 | PWSTR lpszMessageType; | ||
1075 | PWSTR lpszDateReceived; | ||
1076 | PWSTR lpszConversationID; | ||
1077 | FLAGS flFlags; | ||
1078 | Z7_WIN_lpMapiRecipDescW lpOriginator; | ||
1079 | ULONG nRecipCount; | ||
1080 | Z7_WIN_lpMapiRecipDescW lpRecips; | ||
1081 | ULONG nFileCount; | ||
1082 | Z7_WIN_lpMapiFileDescW lpFiles; | ||
1083 | } Z7_WIN_MapiMessageW, *Z7_WIN_lpMapiMessageW; | ||
1084 | |||
1085 | typedef ULONG (FAR PASCAL Z7_WIN_MAPISENDMAILW)( | ||
1086 | LHANDLE lhSession, | ||
1087 | ULONG_PTR ulUIParam, | ||
1088 | Z7_WIN_lpMapiMessageW lpMessage, | ||
1089 | FLAGS flFlags, | ||
1090 | ULONG ulReserved | ||
1091 | ); | ||
1092 | typedef Z7_WIN_MAPISENDMAILW FAR *Z7_WIN_LPMAPISENDMAILW; | ||
1093 | |||
1094 | #endif // MAPI_FORCE_UNICODE | ||
1095 | } | ||
1096 | #endif // _WIN32 | ||
1097 | |||
1098 | |||
1170 | HRESULT UpdateArchive( | 1099 | HRESULT UpdateArchive( |
1171 | CCodecs *codecs, | 1100 | CCodecs *codecs, |
1172 | const CObjectVector<COpenType> &types, | 1101 | const CObjectVector<COpenType> &types, |
@@ -1253,8 +1182,7 @@ HRESULT UpdateArchive( | |||
1253 | if (!options.VolumesSizes.IsEmpty()) | 1182 | if (!options.VolumesSizes.IsEmpty()) |
1254 | { | 1183 | { |
1255 | arcPath = options.ArchivePath.GetFinalVolPath(); | 1184 | arcPath = options.ArchivePath.GetFinalVolPath(); |
1256 | arcPath += '.'; | 1185 | arcPath += ".001"; |
1257 | arcPath += "001"; | ||
1258 | } | 1186 | } |
1259 | 1187 | ||
1260 | if (cmdArcPath2.IsEmpty()) | 1188 | if (cmdArcPath2.IsEmpty()) |
@@ -1268,7 +1196,7 @@ HRESULT UpdateArchive( | |||
1268 | if (!fi.Find_FollowLink(us2fs(arcPath))) | 1196 | if (!fi.Find_FollowLink(us2fs(arcPath))) |
1269 | { | 1197 | { |
1270 | if (renameMode) | 1198 | if (renameMode) |
1271 | throw "can't find archive";; | 1199 | throw "can't find archive"; |
1272 | if (options.MethodMode.Type.FormatIndex < 0) | 1200 | if (options.MethodMode.Type.FormatIndex < 0) |
1273 | { | 1201 | { |
1274 | if (!options.SetArcPath(codecs, cmdArcPath2)) | 1202 | if (!options.SetArcPath(codecs, cmdArcPath2)) |
@@ -1319,7 +1247,7 @@ HRESULT UpdateArchive( | |||
1319 | 1247 | ||
1320 | CIntVector excl; | 1248 | CIntVector excl; |
1321 | COpenOptions op; | 1249 | COpenOptions op; |
1322 | #ifndef _SFX | 1250 | #ifndef Z7_SFX |
1323 | op.props = &options.MethodMode.Properties; | 1251 | op.props = &options.MethodMode.Properties; |
1324 | #endif | 1252 | #endif |
1325 | op.codecs = codecs; | 1253 | op.codecs = codecs; |
@@ -1329,7 +1257,7 @@ HRESULT UpdateArchive( | |||
1329 | op.stream = NULL; | 1257 | op.stream = NULL; |
1330 | op.filePath = arcPath; | 1258 | op.filePath = arcPath; |
1331 | 1259 | ||
1332 | RINOK(callback->StartOpenArchive(arcPath)); | 1260 | RINOK(callback->StartOpenArchive(arcPath)) |
1333 | 1261 | ||
1334 | HRESULT result = arcLink.Open_Strict(op, openCallback); | 1262 | HRESULT result = arcLink.Open_Strict(op, openCallback); |
1335 | 1263 | ||
@@ -1341,8 +1269,8 @@ HRESULT UpdateArchive( | |||
1341 | if (result == S_FALSE) | 1269 | if (result == S_FALSE) |
1342 | return E_FAIL; | 1270 | return E_FAIL; |
1343 | */ | 1271 | */ |
1344 | RINOK(res2); | 1272 | RINOK(res2) |
1345 | RINOK(result); | 1273 | RINOK(result) |
1346 | 1274 | ||
1347 | if (arcLink.VolumePaths.Size() > 1) | 1275 | if (arcLink.VolumePaths.Size() > 1) |
1348 | { | 1276 | { |
@@ -1422,7 +1350,7 @@ HRESULT UpdateArchive( | |||
1422 | 1350 | ||
1423 | if (needScanning) | 1351 | if (needScanning) |
1424 | { | 1352 | { |
1425 | RINOK(callback->StartScanning()); | 1353 | RINOK(callback->StartScanning()) |
1426 | 1354 | ||
1427 | dirItems.SymLinks = options.SymLinks.Val; | 1355 | dirItems.SymLinks = options.SymLinks.Val; |
1428 | 1356 | ||
@@ -1452,7 +1380,7 @@ HRESULT UpdateArchive( | |||
1452 | return res; | 1380 | return res; |
1453 | } | 1381 | } |
1454 | 1382 | ||
1455 | RINOK(callback->FinishScanning(dirItems.Stat)); | 1383 | RINOK(callback->FinishScanning(dirItems.Stat)) |
1456 | 1384 | ||
1457 | // 22.00: we don't need parent folder, if absolute path mode | 1385 | // 22.00: we don't need parent folder, if absolute path mode |
1458 | if (options.PathMode != NWildcard::k_AbsPath) | 1386 | if (options.PathMode != NWildcard::k_AbsPath) |
@@ -1460,7 +1388,7 @@ HRESULT UpdateArchive( | |||
1460 | { | 1388 | { |
1461 | NFind::CFileInfo fi; | 1389 | NFind::CFileInfo fi; |
1462 | FString prefix = us2fs(censor.Pairs[0].Prefix); | 1390 | FString prefix = us2fs(censor.Pairs[0].Prefix); |
1463 | prefix += '.'; | 1391 | prefix.Add_Dot(); |
1464 | // UString prefix = censor.Pairs[0].Prefix; | 1392 | // UString prefix = censor.Pairs[0].Prefix; |
1465 | /* | 1393 | /* |
1466 | if (prefix.Back() == WCHAR_PATH_SEPARATOR) | 1394 | if (prefix.Back() == WCHAR_PATH_SEPARATOR) |
@@ -1576,7 +1504,7 @@ HRESULT UpdateArchive( | |||
1576 | { | 1504 | { |
1577 | RINOK(EnumerateInArchiveItems( | 1505 | RINOK(EnumerateInArchiveItems( |
1578 | // options.StoreAltStreams, | 1506 | // options.StoreAltStreams, |
1579 | censor, arcLink.Arcs.Back(), arcItems)); | 1507 | censor, arcLink.Arcs.Back(), arcItems)) |
1580 | } | 1508 | } |
1581 | 1509 | ||
1582 | /* | 1510 | /* |
@@ -1595,8 +1523,10 @@ HRESULT UpdateArchive( | |||
1595 | processedItems[i] = 0; | 1523 | processedItems[i] = 0; |
1596 | } | 1524 | } |
1597 | 1525 | ||
1526 | CMultiOutStream_Bunch multiStreams; | ||
1527 | |||
1598 | /* | 1528 | /* |
1599 | #ifndef _NO_CRYPTO | 1529 | #ifndef Z7_NO_CRYPTO |
1600 | if (arcLink.PasswordWasAsked) | 1530 | if (arcLink.PasswordWasAsked) |
1601 | { | 1531 | { |
1602 | // We set password, if open have requested password | 1532 | // We set password, if open have requested password |
@@ -1640,18 +1570,22 @@ HRESULT UpdateArchive( | |||
1640 | parentDirItem_Ptr, | 1570 | parentDirItem_Ptr, |
1641 | 1571 | ||
1642 | tempFiles, | 1572 | tempFiles, |
1643 | errorInfo, callback, st)); | 1573 | multiStreams, |
1574 | errorInfo, callback, st)) | ||
1644 | 1575 | ||
1645 | RINOK(callback->FinishArchive(st)); | 1576 | RINOK(callback->FinishArchive(st)) |
1646 | } | 1577 | } |
1647 | 1578 | ||
1648 | 1579 | ||
1649 | if (thereIsInArchive) | 1580 | if (thereIsInArchive) |
1650 | { | 1581 | { |
1651 | RINOK(arcLink.Close()); | 1582 | RINOK(arcLink.Close()) |
1652 | arcLink.Release(); | 1583 | arcLink.Release(); |
1653 | } | 1584 | } |
1654 | 1585 | ||
1586 | multiStreams.DisableDeletion(); | ||
1587 | RINOK(multiStreams.Destruct()) | ||
1588 | |||
1655 | tempFiles.Paths.Clear(); | 1589 | tempFiles.Paths.Clear(); |
1656 | if (createTempFile) | 1590 | if (createTempFile) |
1657 | { | 1591 | { |
@@ -1702,6 +1636,19 @@ HRESULT UpdateArchive( | |||
1702 | return errorInfo.Get_HRESULT_Error(); | 1636 | return errorInfo.Get_HRESULT_Error(); |
1703 | } | 1637 | } |
1704 | 1638 | ||
1639 | FStringVector fullPaths; | ||
1640 | unsigned i; | ||
1641 | |||
1642 | for (i = 0; i < options.Commands.Size(); i++) | ||
1643 | { | ||
1644 | CArchivePath &ap = options.Commands[i].ArchivePath; | ||
1645 | const FString finalPath = us2fs(ap.GetFinalPath()); | ||
1646 | FString arcPath2; | ||
1647 | if (!MyGetFullPathName(finalPath, arcPath2)) | ||
1648 | return errorInfo.SetFromLastError("GetFullPathName error", finalPath); | ||
1649 | fullPaths.Add(arcPath2); | ||
1650 | } | ||
1651 | |||
1705 | /* | 1652 | /* |
1706 | LPMAPISENDDOCUMENTS fnSend = (LPMAPISENDDOCUMENTS)mapiLib.GetProc("MAPISendDocuments"); | 1653 | LPMAPISENDDOCUMENTS fnSend = (LPMAPISENDDOCUMENTS)mapiLib.GetProc("MAPISendDocuments"); |
1707 | if (fnSend == 0) | 1654 | if (fnSend == 0) |
@@ -1710,25 +1657,70 @@ HRESULT UpdateArchive( | |||
1710 | return errorInfo.Get_HRESULT_Error(); | 1657 | return errorInfo.Get_HRESULT_Error(); |
1711 | } | 1658 | } |
1712 | */ | 1659 | */ |
1660 | const | ||
1661 | Z7_WIN_LPMAPISENDMAILW sendMailW = Z7_GET_PROC_ADDRESS( | ||
1662 | Z7_WIN_LPMAPISENDMAILW, mapiLib.Get_HMODULE(), | ||
1663 | "MAPISendMailW"); | ||
1664 | if (sendMailW) | ||
1665 | { | ||
1666 | |||
1667 | CCurrentDirRestorer curDirRestorer; | ||
1668 | |||
1669 | UStringVector paths; | ||
1670 | UStringVector names; | ||
1713 | 1671 | ||
1714 | LPMAPISENDMAIL sendMail = (LPMAPISENDMAIL)(void *)mapiLib.GetProc("MAPISendMail"); | 1672 | for (i = 0; i < fullPaths.Size(); i++) |
1715 | if (sendMail == 0) | ||
1716 | { | 1673 | { |
1717 | errorInfo.SetFromLastError("7-Zip cannot find MAPISendMail function"); | 1674 | const UString arcPath2 = fs2us(fullPaths[i]); |
1718 | return errorInfo.Get_HRESULT_Error();; | 1675 | const UString fileName = ExtractFileNameFromPath(arcPath2); |
1676 | paths.Add(arcPath2); | ||
1677 | names.Add(fileName); | ||
1678 | // Warning!!! MAPISendDocuments function changes Current directory | ||
1679 | // fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0); | ||
1719 | } | 1680 | } |
1720 | 1681 | ||
1721 | FStringVector fullPaths; | 1682 | CRecordVector<Z7_WIN_MapiFileDescW> files; |
1722 | unsigned i; | 1683 | files.ClearAndSetSize(paths.Size()); |
1723 | 1684 | ||
1724 | for (i = 0; i < options.Commands.Size(); i++) | 1685 | for (i = 0; i < paths.Size(); i++) |
1725 | { | 1686 | { |
1726 | CArchivePath &ap = options.Commands[i].ArchivePath; | 1687 | Z7_WIN_MapiFileDescW &f = files[i]; |
1727 | FString finalPath = us2fs(ap.GetFinalPath()); | 1688 | memset(&f, 0, sizeof(f)); |
1728 | FString arcPath2; | 1689 | f.nPosition = 0xFFFFFFFF; |
1729 | if (!MyGetFullPathName(finalPath, arcPath2)) | 1690 | f.lpszPathName = paths[i].Ptr_non_const(); |
1730 | return errorInfo.SetFromLastError("GetFullPathName error", finalPath); | 1691 | f.lpszFileName = names[i].Ptr_non_const(); |
1731 | fullPaths.Add(arcPath2); | 1692 | } |
1693 | |||
1694 | { | ||
1695 | Z7_WIN_MapiMessageW m; | ||
1696 | memset(&m, 0, sizeof(m)); | ||
1697 | m.nFileCount = files.Size(); | ||
1698 | m.lpFiles = &files.Front(); | ||
1699 | |||
1700 | const UString addr (options.EMailAddress); | ||
1701 | Z7_WIN_MapiRecipDescW rec; | ||
1702 | if (!addr.IsEmpty()) | ||
1703 | { | ||
1704 | memset(&rec, 0, sizeof(rec)); | ||
1705 | rec.ulRecipClass = MAPI_TO; | ||
1706 | rec.lpszAddress = addr.Ptr_non_const(); | ||
1707 | m.nRecipCount = 1; | ||
1708 | m.lpRecips = &rec; | ||
1709 | } | ||
1710 | |||
1711 | sendMailW((LHANDLE)0, 0, &m, MAPI_DIALOG, 0); | ||
1712 | } | ||
1713 | } | ||
1714 | else | ||
1715 | { | ||
1716 | const | ||
1717 | LPMAPISENDMAIL sendMail = Z7_GET_PROC_ADDRESS( | ||
1718 | LPMAPISENDMAIL, mapiLib.Get_HMODULE(), | ||
1719 | "MAPISendMail"); | ||
1720 | if (!sendMail) | ||
1721 | { | ||
1722 | errorInfo.SetFromLastError("7-Zip cannot find MAPISendMail function"); | ||
1723 | return errorInfo.Get_HRESULT_Error(); | ||
1732 | } | 1724 | } |
1733 | 1725 | ||
1734 | CCurrentDirRestorer curDirRestorer; | 1726 | CCurrentDirRestorer curDirRestorer; |
@@ -1779,6 +1771,7 @@ HRESULT UpdateArchive( | |||
1779 | 1771 | ||
1780 | sendMail((LHANDLE)0, 0, &m, MAPI_DIALOG, 0); | 1772 | sendMail((LHANDLE)0, 0, &m, MAPI_DIALOG, 0); |
1781 | } | 1773 | } |
1774 | } | ||
1782 | } | 1775 | } |
1783 | 1776 | ||
1784 | #endif | 1777 | #endif |
@@ -1827,7 +1820,7 @@ HRESULT UpdateArchive( | |||
1827 | && Compare_FiTime(&fileInfo.MTime, &dirItem.MTime) == 0 | 1820 | && Compare_FiTime(&fileInfo.MTime, &dirItem.MTime) == 0 |
1828 | && Compare_FiTime(&fileInfo.CTime, &dirItem.CTime) == 0) | 1821 | && Compare_FiTime(&fileInfo.CTime, &dirItem.CTime) == 0) |
1829 | { | 1822 | { |
1830 | RINOK(callback->DeletingAfterArchiving(phyPath, false)); | 1823 | RINOK(callback->DeletingAfterArchiving(phyPath, false)) |
1831 | DeleteFileAlways(phyPath); | 1824 | DeleteFileAlways(phyPath); |
1832 | } | 1825 | } |
1833 | } | 1826 | } |
@@ -1852,12 +1845,12 @@ HRESULT UpdateArchive( | |||
1852 | const FString phyPath = dirItems.GetPhyPath(pairs[i].Index); | 1845 | const FString phyPath = dirItems.GetPhyPath(pairs[i].Index); |
1853 | if (NFind::DoesDirExist(phyPath)) | 1846 | if (NFind::DoesDirExist(phyPath)) |
1854 | { | 1847 | { |
1855 | RINOK(callback->DeletingAfterArchiving(phyPath, true)); | 1848 | RINOK(callback->DeletingAfterArchiving(phyPath, true)) |
1856 | RemoveDir(phyPath); | 1849 | RemoveDir(phyPath); |
1857 | } | 1850 | } |
1858 | } | 1851 | } |
1859 | 1852 | ||
1860 | RINOK(callback->FinishDeletingAfterArchiving()); | 1853 | RINOK(callback->FinishDeletingAfterArchiving()) |
1861 | } | 1854 | } |
1862 | 1855 | ||
1863 | return S_OK; | 1856 | return S_OK; |
diff --git a/CPP/7zip/UI/Common/Update.h b/CPP/7zip/UI/Common/Update.h index 01fc43e..a9459ff 100644 --- a/CPP/7zip/UI/Common/Update.h +++ b/CPP/7zip/UI/Common/Update.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // Update.h | 1 | // Update.h |
2 | 2 | ||
3 | #ifndef __COMMON_UPDATE_H | 3 | #ifndef ZIP7_INC_COMMON_UPDATE_H |
4 | #define __COMMON_UPDATE_H | 4 | #define ZIP7_INC_COMMON_UPDATE_H |
5 | 5 | ||
6 | #include "../../../Common/Wildcard.h" | 6 | #include "../../../Common/Wildcard.h" |
7 | 7 | ||
@@ -34,7 +34,7 @@ struct CArchivePath | |||
34 | FString TempPrefix; // path(folder) for temp location | 34 | FString TempPrefix; // path(folder) for temp location |
35 | FString TempPostfix; | 35 | FString TempPostfix; |
36 | 36 | ||
37 | CArchivePath(): Temp(false) {}; | 37 | CArchivePath(): Temp(false) {} |
38 | 38 | ||
39 | void ParseFromPath(const UString &path, EArcNameMode mode); | 39 | void ParseFromPath(const UString &path, EArcNameMode mode); |
40 | UString GetPathWithoutExt() const { return Prefix + Name; } | 40 | UString GetPathWithoutExt() const { return Prefix + Name; } |
@@ -81,31 +81,21 @@ struct CRenamePair | |||
81 | 81 | ||
82 | struct CUpdateOptions | 82 | struct CUpdateOptions |
83 | { | 83 | { |
84 | CCompressionMethodMode MethodMode; | ||
85 | |||
86 | CObjectVector<CUpdateArchiveCommand> Commands; | ||
87 | bool UpdateArchiveItself; | 84 | bool UpdateArchiveItself; |
88 | CArchivePath ArchivePath; | ||
89 | EArcNameMode ArcNameMode; | ||
90 | |||
91 | bool SfxMode; | 85 | bool SfxMode; |
92 | FString SfxModule; | 86 | |
93 | |||
94 | bool PreserveATime; | 87 | bool PreserveATime; |
95 | bool OpenShareForWrite; | 88 | bool OpenShareForWrite; |
96 | bool StopAfterOpenError; | 89 | bool StopAfterOpenError; |
97 | 90 | ||
98 | bool StdInMode; | 91 | bool StdInMode; |
99 | UString StdInFileName; | ||
100 | bool StdOutMode; | 92 | bool StdOutMode; |
101 | 93 | ||
102 | bool EMailMode; | 94 | bool EMailMode; |
103 | bool EMailRemoveAfter; | 95 | bool EMailRemoveAfter; |
104 | UString EMailAddress; | ||
105 | 96 | ||
106 | FString WorkingDir; | 97 | bool DeleteAfterCompressing; |
107 | NWildcard::ECensorPathMode PathMode; | 98 | bool SetArcMTime; |
108 | // UString AddPathPrefix; | ||
109 | 99 | ||
110 | CBoolPair NtSecurity; | 100 | CBoolPair NtSecurity; |
111 | CBoolPair AltStreams; | 101 | CBoolPair AltStreams; |
@@ -115,19 +105,28 @@ struct CUpdateOptions | |||
115 | CBoolPair StoreOwnerId; | 105 | CBoolPair StoreOwnerId; |
116 | CBoolPair StoreOwnerName; | 106 | CBoolPair StoreOwnerName; |
117 | 107 | ||
118 | bool DeleteAfterCompressing; | 108 | EArcNameMode ArcNameMode; |
109 | NWildcard::ECensorPathMode PathMode; | ||
119 | 110 | ||
120 | bool SetArcMTime; | 111 | CCompressionMethodMode MethodMode; |
112 | |||
113 | CObjectVector<CUpdateArchiveCommand> Commands; | ||
114 | CArchivePath ArchivePath; | ||
115 | |||
116 | FString SfxModule; | ||
117 | UString StdInFileName; | ||
118 | UString EMailAddress; | ||
119 | FString WorkingDir; | ||
120 | // UString AddPathPrefix; | ||
121 | 121 | ||
122 | CObjectVector<CRenamePair> RenamePairs; | 122 | CObjectVector<CRenamePair> RenamePairs; |
123 | CRecordVector<UInt64> VolumesSizes; | ||
123 | 124 | ||
124 | bool InitFormatIndex(const CCodecs *codecs, const CObjectVector<COpenType> &types, const UString &arcPath); | 125 | bool InitFormatIndex(const CCodecs *codecs, const CObjectVector<COpenType> &types, const UString &arcPath); |
125 | bool SetArcPath(const CCodecs *codecs, const UString &arcPath); | 126 | bool SetArcPath(const CCodecs *codecs, const UString &arcPath); |
126 | 127 | ||
127 | CUpdateOptions(): | 128 | CUpdateOptions(): |
128 | UpdateArchiveItself(true), | 129 | UpdateArchiveItself(true), |
129 | ArcNameMode(k_ArcNameMode_Smart), | ||
130 | |||
131 | SfxMode(false), | 130 | SfxMode(false), |
132 | 131 | ||
133 | PreserveATime(false), | 132 | PreserveATime(false), |
@@ -140,12 +139,13 @@ struct CUpdateOptions | |||
140 | EMailMode(false), | 139 | EMailMode(false), |
141 | EMailRemoveAfter(false), | 140 | EMailRemoveAfter(false), |
142 | 141 | ||
143 | PathMode(NWildcard::k_RelatPath), | ||
144 | |||
145 | DeleteAfterCompressing(false), | 142 | DeleteAfterCompressing(false), |
146 | SetArcMTime(false) | 143 | SetArcMTime(false), |
147 | 144 | ||
148 | {}; | 145 | ArcNameMode(k_ArcNameMode_Smart), |
146 | PathMode(NWildcard::k_RelatPath) | ||
147 | |||
148 | {} | ||
149 | 149 | ||
150 | void SetActionCommand_Add() | 150 | void SetActionCommand_Add() |
151 | { | 151 | { |
@@ -154,10 +154,9 @@ struct CUpdateOptions | |||
154 | c.ActionSet = NUpdateArchive::k_ActionSet_Add; | 154 | c.ActionSet = NUpdateArchive::k_ActionSet_Add; |
155 | Commands.Add(c); | 155 | Commands.Add(c); |
156 | } | 156 | } |
157 | |||
158 | CRecordVector<UInt64> VolumesSizes; | ||
159 | }; | 157 | }; |
160 | 158 | ||
159 | |||
161 | struct CUpdateErrorInfo | 160 | struct CUpdateErrorInfo |
162 | { | 161 | { |
163 | DWORD SystemError; // it's DWORD (WRes) only; | 162 | DWORD SystemError; // it's DWORD (WRes) only; |
@@ -170,32 +169,40 @@ struct CUpdateErrorInfo | |||
170 | HRESULT SetFromLastError(const char *message, const FString &fileName); | 169 | HRESULT SetFromLastError(const char *message, const FString &fileName); |
171 | HRESULT SetFromError_DWORD(const char *message, const FString &fileName, DWORD error); | 170 | HRESULT SetFromError_DWORD(const char *message, const FString &fileName, DWORD error); |
172 | 171 | ||
173 | CUpdateErrorInfo(): SystemError(0) {}; | 172 | CUpdateErrorInfo(): SystemError(0) {} |
174 | }; | 173 | }; |
175 | 174 | ||
176 | struct CFinishArchiveStat | 175 | struct CFinishArchiveStat |
177 | { | 176 | { |
178 | UInt64 OutArcFileSize; | 177 | UInt64 OutArcFileSize; |
178 | unsigned NumVolumes; | ||
179 | bool IsMultiVolMode; | ||
179 | 180 | ||
180 | CFinishArchiveStat(): OutArcFileSize(0) {} | 181 | CFinishArchiveStat(): OutArcFileSize(0), NumVolumes(0), IsMultiVolMode(false) {} |
181 | }; | 182 | }; |
182 | 183 | ||
183 | #define INTERFACE_IUpdateCallbackUI2(x) \ | 184 | Z7_PURE_INTERFACES_BEGIN |
184 | INTERFACE_IUpdateCallbackUI(x) \ | 185 | |
185 | INTERFACE_IDirItemsCallback(x) \ | 186 | // INTERFACE_IUpdateCallbackUI(x) |
186 | virtual HRESULT OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result) x; \ | 187 | // INTERFACE_IDirItemsCallback(x) |
187 | virtual HRESULT StartScanning() x; \ | 188 | |
188 | virtual HRESULT FinishScanning(const CDirItemsStat &st) x; \ | 189 | #define Z7_IFACEN_IUpdateCallbackUI2(x) \ |
189 | virtual HRESULT StartOpenArchive(const wchar_t *name) x; \ | 190 | virtual HRESULT OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result) x \ |
190 | virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \ | 191 | virtual HRESULT StartScanning() x \ |
191 | virtual HRESULT FinishArchive(const CFinishArchiveStat &st) x; \ | 192 | virtual HRESULT FinishScanning(const CDirItemsStat &st) x \ |
192 | virtual HRESULT DeletingAfterArchiving(const FString &path, bool isDir) x; \ | 193 | virtual HRESULT StartOpenArchive(const wchar_t *name) x \ |
193 | virtual HRESULT FinishDeletingAfterArchiving() x; \ | 194 | virtual HRESULT StartArchive(const wchar_t *name, bool updating) x \ |
194 | 195 | virtual HRESULT FinishArchive(const CFinishArchiveStat &st) x \ | |
195 | struct IUpdateCallbackUI2: public IUpdateCallbackUI, public IDirItemsCallback | 196 | virtual HRESULT DeletingAfterArchiving(const FString &path, bool isDir) x \ |
197 | virtual HRESULT FinishDeletingAfterArchiving() x \ | ||
198 | |||
199 | DECLARE_INTERFACE(IUpdateCallbackUI2): | ||
200 | public IUpdateCallbackUI, | ||
201 | public IDirItemsCallback | ||
196 | { | 202 | { |
197 | INTERFACE_IUpdateCallbackUI2(=0) | 203 | Z7_IFACE_PURE(IUpdateCallbackUI2) |
198 | }; | 204 | }; |
205 | Z7_PURE_INTERFACES_END | ||
199 | 206 | ||
200 | HRESULT UpdateArchive( | 207 | HRESULT UpdateArchive( |
201 | CCodecs *codecs, | 208 | CCodecs *codecs, |
diff --git a/CPP/7zip/UI/Common/UpdateAction.h b/CPP/7zip/UI/Common/UpdateAction.h index bc53fcd..6a3565e 100644 --- a/CPP/7zip/UI/Common/UpdateAction.h +++ b/CPP/7zip/UI/Common/UpdateAction.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // UpdateAction.h | 1 | // UpdateAction.h |
2 | 2 | ||
3 | #ifndef __UPDATE_ACTION_H | 3 | #ifndef ZIP7_INC_UPDATE_ACTION_H |
4 | #define __UPDATE_ACTION_H | 4 | #define ZIP7_INC_UPDATE_ACTION_H |
5 | 5 | ||
6 | namespace NUpdateArchive { | 6 | namespace NUpdateArchive { |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/UpdateCallback.cpp b/CPP/7zip/UI/Common/UpdateCallback.cpp index c93bfc7..5e2860d 100644 --- a/CPP/7zip/UI/Common/UpdateCallback.cpp +++ b/CPP/7zip/UI/Common/UpdateCallback.cpp | |||
@@ -7,17 +7,23 @@ | |||
7 | #ifndef _WIN32 | 7 | #ifndef _WIN32 |
8 | // #include <grp.h> | 8 | // #include <grp.h> |
9 | // #include <pwd.h> | 9 | // #include <pwd.h> |
10 | 10 | /* | |
11 | inclusion of <sys/sysmacros.h> by <sys/types.h> is deprecated since glibc 2.25. | ||
12 | Since glibc 2.3.3, macros have been aliases for three GNU-specific | ||
13 | functions: gnu_dev_makedev(), gnu_dev_major(), and gnu_dev_minor() | ||
14 | */ | ||
11 | // for major()/minor(): | 15 | // for major()/minor(): |
12 | #if defined(__FreeBSD__) || defined(BSD) | ||
13 | #include <sys/types.h> | 16 | #include <sys/types.h> |
17 | #if defined(__FreeBSD__) || defined(BSD) || defined(__APPLE__) | ||
14 | #else | 18 | #else |
19 | #ifndef major | ||
15 | #include <sys/sysmacros.h> | 20 | #include <sys/sysmacros.h> |
16 | #endif | 21 | #endif |
17 | |||
18 | #endif | 22 | #endif |
19 | 23 | ||
20 | #ifndef _7ZIP_ST | 24 | #endif // _WIN32 |
25 | |||
26 | #ifndef Z7_ST | ||
21 | #include "../../../Windows/Synchronization.h" | 27 | #include "../../../Windows/Synchronization.h" |
22 | #endif | 28 | #endif |
23 | 29 | ||
@@ -36,14 +42,14 @@ | |||
36 | #include "UpdateCallback.h" | 42 | #include "UpdateCallback.h" |
37 | 43 | ||
38 | #if defined(_WIN32) && !defined(UNDER_CE) | 44 | #if defined(_WIN32) && !defined(UNDER_CE) |
39 | #define _USE_SECURITY_CODE | 45 | #define Z7_USE_SECURITY_CODE |
40 | #include "../../../Windows/SecurityUtils.h" | 46 | #include "../../../Windows/SecurityUtils.h" |
41 | #endif | 47 | #endif |
42 | 48 | ||
43 | using namespace NWindows; | 49 | using namespace NWindows; |
44 | using namespace NFile; | 50 | using namespace NFile; |
45 | 51 | ||
46 | #ifndef _7ZIP_ST | 52 | #ifndef Z7_ST |
47 | static NSynchronization::CCriticalSection g_CriticalSection; | 53 | static NSynchronization::CCriticalSection g_CriticalSection; |
48 | #define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection); | 54 | #define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection); |
49 | #else | 55 | #else |
@@ -51,25 +57,11 @@ static NSynchronization::CCriticalSection g_CriticalSection; | |||
51 | #endif | 57 | #endif |
52 | 58 | ||
53 | 59 | ||
54 | #ifdef _USE_SECURITY_CODE | 60 | #ifdef Z7_USE_SECURITY_CODE |
55 | bool InitLocalPrivileges(); | 61 | bool InitLocalPrivileges(); |
56 | #endif | 62 | #endif |
57 | 63 | ||
58 | CArchiveUpdateCallback::CArchiveUpdateCallback(): | 64 | CArchiveUpdateCallback::CArchiveUpdateCallback(): |
59 | _hardIndex_From((UInt32)(Int32)-1), | ||
60 | |||
61 | Callback(NULL), | ||
62 | |||
63 | DirItems(NULL), | ||
64 | ParentDirItem(NULL), | ||
65 | |||
66 | Arc(NULL), | ||
67 | ArcItems(NULL), | ||
68 | UpdatePairs(NULL), | ||
69 | NewNames(NULL), | ||
70 | CommentIndex(-1), | ||
71 | Comment(NULL), | ||
72 | |||
73 | PreserveATime(false), | 65 | PreserveATime(false), |
74 | ShareForWrite(false), | 66 | ShareForWrite(false), |
75 | StopAfterOpenError(false), | 67 | StopAfterOpenError(false), |
@@ -92,29 +84,42 @@ CArchiveUpdateCallback::CArchiveUpdateCallback(): | |||
92 | Need_LatestMTime(false), | 84 | Need_LatestMTime(false), |
93 | LatestMTime_Defined(false), | 85 | LatestMTime_Defined(false), |
94 | 86 | ||
95 | ProcessedItemsStatuses(NULL) | 87 | Callback(NULL), |
88 | |||
89 | DirItems(NULL), | ||
90 | ParentDirItem(NULL), | ||
91 | |||
92 | Arc(NULL), | ||
93 | ArcItems(NULL), | ||
94 | UpdatePairs(NULL), | ||
95 | NewNames(NULL), | ||
96 | Comment(NULL), | ||
97 | CommentIndex(-1), | ||
98 | |||
99 | ProcessedItemsStatuses(NULL), | ||
100 | _hardIndex_From((UInt32)(Int32)-1) | ||
96 | { | 101 | { |
97 | #ifdef _USE_SECURITY_CODE | 102 | #ifdef Z7_USE_SECURITY_CODE |
98 | _saclEnabled = InitLocalPrivileges(); | 103 | _saclEnabled = InitLocalPrivileges(); |
99 | #endif | 104 | #endif |
100 | } | 105 | } |
101 | 106 | ||
102 | 107 | ||
103 | STDMETHODIMP CArchiveUpdateCallback::SetTotal(UInt64 size) | 108 | Z7_COM7F_IMF(CArchiveUpdateCallback::SetTotal(UInt64 size)) |
104 | { | 109 | { |
105 | COM_TRY_BEGIN | 110 | COM_TRY_BEGIN |
106 | return Callback->SetTotal(size); | 111 | return Callback->SetTotal(size); |
107 | COM_TRY_END | 112 | COM_TRY_END |
108 | } | 113 | } |
109 | 114 | ||
110 | STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 *completeValue) | 115 | Z7_COM7F_IMF(CArchiveUpdateCallback::SetCompleted(const UInt64 *completeValue)) |
111 | { | 116 | { |
112 | COM_TRY_BEGIN | 117 | COM_TRY_BEGIN |
113 | return Callback->SetCompleted(completeValue); | 118 | return Callback->SetCompleted(completeValue); |
114 | COM_TRY_END | 119 | COM_TRY_END |
115 | } | 120 | } |
116 | 121 | ||
117 | STDMETHODIMP CArchiveUpdateCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) | 122 | Z7_COM7F_IMF(CArchiveUpdateCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)) |
118 | { | 123 | { |
119 | COM_TRY_BEGIN | 124 | COM_TRY_BEGIN |
120 | return Callback->SetRatioInfo(inSize, outSize); | 125 | return Callback->SetRatioInfo(inSize, outSize); |
@@ -135,17 +140,17 @@ static const CStatProp kProps[] = | |||
135 | { NULL, kpidIsAnti, VT_BOOL} | 140 | { NULL, kpidIsAnti, VT_BOOL} |
136 | }; | 141 | }; |
137 | 142 | ||
138 | STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG **) | 143 | Z7_COM7F_IMF(CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG **) |
139 | { | 144 | { |
140 | return CStatPropEnumerator::CreateEnumerator(kProps, ARRAY_SIZE(kProps), enumerator); | 145 | return CStatPropEnumerator::CreateEnumerator(kProps, Z7_ARRAY_SIZE(kProps), enumerator); |
141 | } | 146 | } |
142 | */ | 147 | */ |
143 | 148 | ||
144 | STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index, | 149 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index, |
145 | Int32 *newData, Int32 *newProps, UInt32 *indexInArchive) | 150 | Int32 *newData, Int32 *newProps, UInt32 *indexInArchive)) |
146 | { | 151 | { |
147 | COM_TRY_BEGIN | 152 | COM_TRY_BEGIN |
148 | RINOK(Callback->CheckBreak()); | 153 | RINOK(Callback->CheckBreak()) |
149 | const CUpdatePair2 &up = (*UpdatePairs)[index]; | 154 | const CUpdatePair2 &up = (*UpdatePairs)[index]; |
150 | if (newData) *newData = BoolToInt(up.NewData); | 155 | if (newData) *newData = BoolToInt(up.NewData); |
151 | if (newProps) *newProps = BoolToInt(up.NewProps); | 156 | if (newProps) *newProps = BoolToInt(up.NewProps); |
@@ -160,7 +165,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index, | |||
160 | } | 165 | } |
161 | 166 | ||
162 | 167 | ||
163 | STDMETHODIMP CArchiveUpdateCallback::GetRootProp(PROPID propID, PROPVARIANT *value) | 168 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetRootProp(PROPID propID, PROPVARIANT *value)) |
164 | { | 169 | { |
165 | NCOM::CPropVariant prop; | 170 | NCOM::CPropVariant prop; |
166 | switch (propID) | 171 | switch (propID) |
@@ -176,14 +181,14 @@ STDMETHODIMP CArchiveUpdateCallback::GetRootProp(PROPID propID, PROPVARIANT *val | |||
176 | return S_OK; | 181 | return S_OK; |
177 | } | 182 | } |
178 | 183 | ||
179 | STDMETHODIMP CArchiveUpdateCallback::GetParent(UInt32 /* index */, UInt32 *parent, UInt32 *parentType) | 184 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetParent(UInt32 /* index */, UInt32 *parent, UInt32 *parentType)) |
180 | { | 185 | { |
181 | *parentType = NParentType::kDir; | 186 | *parentType = NParentType::kDir; |
182 | *parent = (UInt32)(Int32)-1; | 187 | *parent = (UInt32)(Int32)-1; |
183 | return S_OK; | 188 | return S_OK; |
184 | } | 189 | } |
185 | 190 | ||
186 | STDMETHODIMP CArchiveUpdateCallback::GetNumRawProps(UInt32 *numProps) | 191 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetNumRawProps(UInt32 *numProps)) |
187 | { | 192 | { |
188 | *numProps = 0; | 193 | *numProps = 0; |
189 | if (StoreNtSecurity) | 194 | if (StoreNtSecurity) |
@@ -191,25 +196,27 @@ STDMETHODIMP CArchiveUpdateCallback::GetNumRawProps(UInt32 *numProps) | |||
191 | return S_OK; | 196 | return S_OK; |
192 | } | 197 | } |
193 | 198 | ||
194 | STDMETHODIMP CArchiveUpdateCallback::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID) | 199 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID)) |
195 | { | 200 | { |
196 | *name = NULL; | 201 | *name = NULL; |
197 | *propID = kpidNtSecure; | 202 | *propID = kpidNtSecure; |
198 | return S_OK; | 203 | return S_OK; |
199 | } | 204 | } |
200 | 205 | ||
201 | STDMETHODIMP CArchiveUpdateCallback::GetRootRawProp(PROPID | 206 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetRootRawProp(PROPID |
202 | #ifdef _USE_SECURITY_CODE | ||
203 | propID | 207 | propID |
204 | #endif | 208 | , const void **data, UInt32 *dataSize, UInt32 *propType)) |
205 | , const void **data, UInt32 *dataSize, UInt32 *propType) | ||
206 | { | 209 | { |
207 | *data = 0; | 210 | #ifndef Z7_USE_SECURITY_CODE |
211 | UNUSED_VAR(propID) | ||
212 | #endif | ||
213 | |||
214 | *data = NULL; | ||
208 | *dataSize = 0; | 215 | *dataSize = 0; |
209 | *propType = 0; | 216 | *propType = 0; |
210 | if (!StoreNtSecurity) | 217 | if (!StoreNtSecurity) |
211 | return S_OK; | 218 | return S_OK; |
212 | #ifdef _USE_SECURITY_CODE | 219 | #ifdef Z7_USE_SECURITY_CODE |
213 | if (propID == kpidNtSecure) | 220 | if (propID == kpidNtSecure) |
214 | { | 221 | { |
215 | if (StdInMode) | 222 | if (StdInMode) |
@@ -233,12 +240,10 @@ STDMETHODIMP CArchiveUpdateCallback::GetRootRawProp(PROPID | |||
233 | return S_OK; | 240 | return S_OK; |
234 | } | 241 | } |
235 | 242 | ||
236 | // #ifdef _USE_SECURITY_CODE | ||
237 | // #endif | ||
238 | 243 | ||
239 | STDMETHODIMP CArchiveUpdateCallback::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType) | 244 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)) |
240 | { | 245 | { |
241 | *data = 0; | 246 | *data = NULL; |
242 | *dataSize = 0; | 247 | *dataSize = 0; |
243 | *propType = 0; | 248 | *propType = 0; |
244 | 249 | ||
@@ -265,7 +270,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetRawProp(UInt32 index, PROPID propID, con | |||
265 | const CDirItem &di = DirItems->Items[(unsigned)up.DirIndex]; | 270 | const CDirItem &di = DirItems->Items[(unsigned)up.DirIndex]; |
266 | #endif | 271 | #endif |
267 | 272 | ||
268 | #ifdef _USE_SECURITY_CODE | 273 | #ifdef Z7_USE_SECURITY_CODE |
269 | if (propID == kpidNtSecure) | 274 | if (propID == kpidNtSecure) |
270 | { | 275 | { |
271 | if (!StoreNtSecurity) | 276 | if (!StoreNtSecurity) |
@@ -349,7 +354,7 @@ static UString GetRelativePath(const UString &to, const UString &from) | |||
349 | 354 | ||
350 | #endif | 355 | #endif |
351 | 356 | ||
352 | STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) | 357 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)) |
353 | { | 358 | { |
354 | COM_TRY_BEGIN | 359 | COM_TRY_BEGIN |
355 | const CUpdatePair2 &up = (*UpdatePairs)[index]; | 360 | const CUpdatePair2 &up = (*UpdatePairs)[index]; |
@@ -385,7 +390,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR | |||
385 | CReparseAttr attr; | 390 | CReparseAttr attr; |
386 | if (attr.Parse(di.ReparseData, di.ReparseData.Size())) | 391 | if (attr.Parse(di.ReparseData, di.ReparseData.Size())) |
387 | { | 392 | { |
388 | UString simpleName = attr.GetPath(); | 393 | const UString simpleName = attr.GetPath(); |
389 | if (!attr.IsSymLink_WSL() && attr.IsRelative_Win()) | 394 | if (!attr.IsSymLink_WSL() && attr.IsRelative_Win()) |
390 | prop = simpleName; | 395 | prop = simpleName; |
391 | else | 396 | else |
@@ -484,6 +489,11 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR | |||
484 | // case kpidShortName: prop = di.ShortName; break; | 489 | // case kpidShortName: prop = di.ShortName; break; |
485 | #else | 490 | #else |
486 | 491 | ||
492 | #if defined(__APPLE__) | ||
493 | #pragma GCC diagnostic push | ||
494 | #pragma GCC diagnostic ignored "-Wsign-conversion" | ||
495 | #endif | ||
496 | |||
487 | case kpidDeviceMajor: | 497 | case kpidDeviceMajor: |
488 | /* | 498 | /* |
489 | printf("\ndi.mode = %o\n", di.mode); | 499 | printf("\ndi.mode = %o\n", di.mode); |
@@ -499,6 +509,10 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR | |||
499 | prop = (UInt32)minor(di.rdev); | 509 | prop = (UInt32)minor(di.rdev); |
500 | break; | 510 | break; |
501 | 511 | ||
512 | #if defined(__APPLE__) | ||
513 | #pragma GCC diagnostic pop | ||
514 | #endif | ||
515 | |||
502 | // case kpidDevice: if (S_ISCHR(di.mode) || S_ISBLK(di.mode)) prop = (UInt64)(di.rdev); break; | 516 | // case kpidDevice: if (S_ISCHR(di.mode) || S_ISBLK(di.mode)) prop = (UInt64)(di.rdev); break; |
503 | 517 | ||
504 | case kpidUserId: if (StoreOwnerId) prop = (UInt32)di.uid; break; | 518 | case kpidUserId: if (StoreOwnerId) prop = (UInt32)di.uid; break; |
@@ -519,22 +533,22 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR | |||
519 | COM_TRY_END | 533 | COM_TRY_END |
520 | } | 534 | } |
521 | 535 | ||
522 | #ifndef _7ZIP_ST | 536 | #ifndef Z7_ST |
523 | static NSynchronization::CCriticalSection CS; | 537 | static NSynchronization::CCriticalSection g_CS; |
524 | #endif | 538 | #endif |
525 | 539 | ||
526 | void CArchiveUpdateCallback::UpdateProcessedItemStatus(unsigned dirIndex) | 540 | void CArchiveUpdateCallback::UpdateProcessedItemStatus(unsigned dirIndex) |
527 | { | 541 | { |
528 | if (ProcessedItemsStatuses) | 542 | if (ProcessedItemsStatuses) |
529 | { | 543 | { |
530 | #ifndef _7ZIP_ST | 544 | #ifndef Z7_ST |
531 | NSynchronization::CCriticalSectionLock lock(CS); | 545 | NSynchronization::CCriticalSectionLock lock(g_CS); |
532 | #endif | 546 | #endif |
533 | ProcessedItemsStatuses[dirIndex] = 1; | 547 | ProcessedItemsStatuses[dirIndex] = 1; |
534 | } | 548 | } |
535 | } | 549 | } |
536 | 550 | ||
537 | STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStream **inStream, UInt32 mode) | 551 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStream **inStream, UInt32 mode)) |
538 | { | 552 | { |
539 | COM_TRY_BEGIN | 553 | COM_TRY_BEGIN |
540 | *inStream = NULL; | 554 | *inStream = NULL; |
@@ -542,7 +556,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
542 | if (!up.NewData) | 556 | if (!up.NewData) |
543 | return E_FAIL; | 557 | return E_FAIL; |
544 | 558 | ||
545 | RINOK(Callback->CheckBreak()); | 559 | RINOK(Callback->CheckBreak()) |
546 | // RINOK(Callback->Finalize()); | 560 | // RINOK(Callback->Finalize()); |
547 | 561 | ||
548 | bool isDir = IsDir(up); | 562 | bool isDir = IsDir(up); |
@@ -554,7 +568,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
554 | name = (*ArcItems)[(unsigned)up.ArcIndex].Name; | 568 | name = (*ArcItems)[(unsigned)up.ArcIndex].Name; |
555 | else if (up.DirIndex >= 0) | 569 | else if (up.DirIndex >= 0) |
556 | name = DirItems->GetLogPath((unsigned)up.DirIndex); | 570 | name = DirItems->GetLogPath((unsigned)up.DirIndex); |
557 | RINOK(Callback->GetStream(name, isDir, true, mode)); | 571 | RINOK(Callback->GetStream(name, isDir, true, mode)) |
558 | 572 | ||
559 | /* 9.33: fixed. Handlers expect real stream object for files, even for anti-file. | 573 | /* 9.33: fixed. Handlers expect real stream object for files, even for anti-file. |
560 | so we return empty stream */ | 574 | so we return empty stream */ |
@@ -569,7 +583,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
569 | return S_OK; | 583 | return S_OK; |
570 | } | 584 | } |
571 | 585 | ||
572 | RINOK(Callback->GetStream(DirItems->GetLogPath((unsigned)up.DirIndex), isDir, false, mode)); | 586 | RINOK(Callback->GetStream(DirItems->GetLogPath((unsigned)up.DirIndex), isDir, false, mode)) |
573 | 587 | ||
574 | if (isDir) | 588 | if (isDir) |
575 | return S_OK; | 589 | return S_OK; |
@@ -640,8 +654,9 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
640 | #endif | 654 | #endif |
641 | 655 | ||
642 | inStreamSpec->SupportHardLinks = StoreHardLinks; | 656 | inStreamSpec->SupportHardLinks = StoreHardLinks; |
643 | inStreamSpec->Set_PreserveATime(PreserveATime | 657 | const bool preserveATime = (PreserveATime |
644 | || mode == NUpdateNotifyOp::kAnalyze); // 22.00 : we don't change access time in Analyze pass. | 658 | || mode == NUpdateNotifyOp::kAnalyze); // 22.00 : we don't change access time in Analyze pass. |
659 | inStreamSpec->Set_PreserveATime(preserveATime); | ||
645 | 660 | ||
646 | const FString path = DirItems->GetPhyPath((unsigned)up.DirIndex); | 661 | const FString path = DirItems->GetPhyPath((unsigned)up.DirIndex); |
647 | _openFiles_Indexes.Add(index); | 662 | _openFiles_Indexes.Add(index); |
@@ -655,12 +670,32 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
655 | 670 | ||
656 | if (!inStreamSpec->OpenShared(path, ShareForWrite)) | 671 | if (!inStreamSpec->OpenShared(path, ShareForWrite)) |
657 | { | 672 | { |
658 | const DWORD error = ::GetLastError(); | 673 | bool isOpen = false; |
659 | const HRESULT hres = Callback->OpenFileError(path, error); | 674 | if (preserveATime) |
660 | if (StopAfterOpenError) | 675 | { |
676 | inStreamSpec->Set_PreserveATime(false); | ||
677 | isOpen = inStreamSpec->OpenShared(path, ShareForWrite); | ||
678 | } | ||
679 | if (!isOpen) | ||
680 | { | ||
681 | const DWORD error = ::GetLastError(); | ||
682 | const HRESULT hres = Callback->OpenFileError(path, error); | ||
661 | if (hres == S_OK || hres == S_FALSE) | 683 | if (hres == S_OK || hres == S_FALSE) |
684 | if (StopAfterOpenError || | ||
685 | // v23: we check also for some critical errors: | ||
686 | #ifdef _WIN32 | ||
687 | error == ERROR_NO_SYSTEM_RESOURCES | ||
688 | #else | ||
689 | error == EMFILE | ||
690 | #endif | ||
691 | ) | ||
692 | { | ||
693 | if (error == 0) | ||
694 | return E_FAIL; | ||
662 | return HRESULT_FROM_WIN32(error); | 695 | return HRESULT_FROM_WIN32(error); |
663 | return hres; | 696 | } |
697 | return hres; | ||
698 | } | ||
664 | } | 699 | } |
665 | 700 | ||
666 | /* | 701 | /* |
@@ -679,7 +714,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
679 | inStreamSpec->ReloadProps(); | 714 | inStreamSpec->ReloadProps(); |
680 | } | 715 | } |
681 | 716 | ||
682 | // #if defined(USE_WIN_FILE) || !defined(_WIN32) | 717 | // #if defined(Z7_FILE_STREAMS_USE_WIN_FILE) || !defined(_WIN32) |
683 | if (StoreHardLinks) | 718 | if (StoreHardLinks) |
684 | { | 719 | { |
685 | CStreamFileProps props; | 720 | CStreamFileProps props; |
@@ -691,8 +726,8 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
691 | pair.Key1 = props.VolID; | 726 | pair.Key1 = props.VolID; |
692 | pair.Key2 = props.FileID_Low; | 727 | pair.Key2 = props.FileID_Low; |
693 | pair.Value = index; | 728 | pair.Value = index; |
694 | unsigned numItems = _map.Size(); | 729 | const unsigned numItems = _map.Size(); |
695 | unsigned pairIndex = _map.AddToUniqueSorted2(pair); | 730 | const unsigned pairIndex = _map.AddToUniqueSorted2(pair); |
696 | if (numItems == _map.Size()) | 731 | if (numItems == _map.Size()) |
697 | { | 732 | { |
698 | // const CKeyKeyValPair &pair2 = _map.Pairs[pairIndex]; | 733 | // const CKeyKeyValPair &pair2 = _map.Pairs[pairIndex]; |
@@ -714,14 +749,14 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea | |||
714 | COM_TRY_END | 749 | COM_TRY_END |
715 | } | 750 | } |
716 | 751 | ||
717 | STDMETHODIMP CArchiveUpdateCallback::SetOperationResult(Int32 opRes) | 752 | Z7_COM7F_IMF(CArchiveUpdateCallback::SetOperationResult(Int32 opRes)) |
718 | { | 753 | { |
719 | COM_TRY_BEGIN | 754 | COM_TRY_BEGIN |
720 | return Callback->SetOperationResult(opRes); | 755 | return Callback->SetOperationResult(opRes); |
721 | COM_TRY_END | 756 | COM_TRY_END |
722 | } | 757 | } |
723 | 758 | ||
724 | STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream) | 759 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)) |
725 | { | 760 | { |
726 | COM_TRY_BEGIN | 761 | COM_TRY_BEGIN |
727 | return GetStream2(index, inStream, | 762 | return GetStream2(index, inStream, |
@@ -731,7 +766,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream | |||
731 | COM_TRY_END | 766 | COM_TRY_END |
732 | } | 767 | } |
733 | 768 | ||
734 | STDMETHODIMP CArchiveUpdateCallback::ReportOperation(UInt32 indexType, UInt32 index, UInt32 op) | 769 | Z7_COM7F_IMF(CArchiveUpdateCallback::ReportOperation(UInt32 indexType, UInt32 index, UInt32 op)) |
735 | { | 770 | { |
736 | COM_TRY_BEGIN | 771 | COM_TRY_BEGIN |
737 | 772 | ||
@@ -770,9 +805,9 @@ STDMETHODIMP CArchiveUpdateCallback::ReportOperation(UInt32 indexType, UInt32 in | |||
770 | } | 805 | } |
771 | else if (Arc) | 806 | else if (Arc) |
772 | { | 807 | { |
773 | RINOK(Arc->GetItem_Path(index, s2)); | 808 | RINOK(Arc->GetItem_Path(index, s2)) |
774 | s = s2; | 809 | s = s2; |
775 | RINOK(Archive_IsItem_Dir(Arc->Archive, index, isDir)); | 810 | RINOK(Archive_IsItem_Dir(Arc->Archive, index, isDir)) |
776 | } | 811 | } |
777 | } | 812 | } |
778 | } | 813 | } |
@@ -791,7 +826,7 @@ STDMETHODIMP CArchiveUpdateCallback::ReportOperation(UInt32 indexType, UInt32 in | |||
791 | COM_TRY_END | 826 | COM_TRY_END |
792 | } | 827 | } |
793 | 828 | ||
794 | STDMETHODIMP CArchiveUpdateCallback::ReportExtractResult(UInt32 indexType, UInt32 index, Int32 opRes) | 829 | Z7_COM7F_IMF(CArchiveUpdateCallback::ReportExtractResult(UInt32 indexType, UInt32 index, Int32 opRes)) |
795 | { | 830 | { |
796 | COM_TRY_BEGIN | 831 | COM_TRY_BEGIN |
797 | 832 | ||
@@ -825,12 +860,12 @@ STDMETHODIMP CArchiveUpdateCallback::ReportExtractResult(UInt32 indexType, UInt3 | |||
825 | s = (*ArcItems)[index].Name; | 860 | s = (*ArcItems)[index].Name; |
826 | else if (Arc) | 861 | else if (Arc) |
827 | { | 862 | { |
828 | RINOK(Arc->GetItem_Path(index, s2)); | 863 | RINOK(Arc->GetItem_Path(index, s2)) |
829 | s = s2; | 864 | s = s2; |
830 | } | 865 | } |
831 | if (Archive) | 866 | if (Archive) |
832 | { | 867 | { |
833 | RINOK(Archive_GetItemBoolProp(Archive, index, kpidEncrypted, isEncrypted)); | 868 | RINOK(Archive_GetItemBoolProp(Archive, index, kpidEncrypted, isEncrypted)) |
834 | } | 869 | } |
835 | } | 870 | } |
836 | } | 871 | } |
@@ -848,7 +883,7 @@ STDMETHODIMP CArchiveUpdateCallback::ReportExtractResult(UInt32 indexType, UInt3 | |||
848 | 883 | ||
849 | 884 | ||
850 | /* | 885 | /* |
851 | STDMETHODIMP CArchiveUpdateCallback::DoNeedArcProp(PROPID propID, Int32 *answer) | 886 | Z7_COM7F_IMF(CArchiveUpdateCallback::DoNeedArcProp(PROPID propID, Int32 *answer)) |
852 | { | 887 | { |
853 | *answer = 0; | 888 | *answer = 0; |
854 | if (Need_ArcMTime_Report && propID == kpidComboMTime) | 889 | if (Need_ArcMTime_Report && propID == kpidComboMTime) |
@@ -856,7 +891,7 @@ STDMETHODIMP CArchiveUpdateCallback::DoNeedArcProp(PROPID propID, Int32 *answer) | |||
856 | return S_OK; | 891 | return S_OK; |
857 | } | 892 | } |
858 | 893 | ||
859 | STDMETHODIMP CArchiveUpdateCallback::ReportProp(UInt32 indexType, UInt32 index, PROPID propID, const PROPVARIANT *value) | 894 | Z7_COM7F_IMF(CArchiveUpdateCallback::ReportProp(UInt32 indexType, UInt32 index, PROPID propID, const PROPVARIANT *value)) |
860 | { | 895 | { |
861 | if (indexType == NArchive::NEventIndexType::kArcProp) | 896 | if (indexType == NArchive::NEventIndexType::kArcProp) |
862 | { | 897 | { |
@@ -879,19 +914,19 @@ STDMETHODIMP CArchiveUpdateCallback::ReportProp(UInt32 indexType, UInt32 index, | |||
879 | return Callback->ReportProp(indexType, index, propID, value); | 914 | return Callback->ReportProp(indexType, index, propID, value); |
880 | } | 915 | } |
881 | 916 | ||
882 | STDMETHODIMP CArchiveUpdateCallback::ReportRawProp(UInt32 indexType, UInt32 index, | 917 | Z7_COM7F_IMF(CArchiveUpdateCallback::ReportRawProp(UInt32 indexType, UInt32 index, |
883 | PROPID propID, const void *data, UInt32 dataSize, UInt32 propType) | 918 | PROPID propID, const void *data, UInt32 dataSize, UInt32 propType)) |
884 | { | 919 | { |
885 | return Callback->ReportRawProp(indexType, index, propID, data, dataSize, propType); | 920 | return Callback->ReportRawProp(indexType, index, propID, data, dataSize, propType); |
886 | } | 921 | } |
887 | 922 | ||
888 | STDMETHODIMP CArchiveUpdateCallback::ReportFinished(UInt32 indexType, UInt32 index, Int32 opRes) | 923 | Z7_COM7F_IMF(CArchiveUpdateCallback::ReportFinished(UInt32 indexType, UInt32 index, Int32 opRes)) |
889 | { | 924 | { |
890 | return Callback->ReportFinished(indexType, index, opRes); | 925 | return Callback->ReportFinished(indexType, index, opRes); |
891 | } | 926 | } |
892 | */ | 927 | */ |
893 | 928 | ||
894 | STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size) | 929 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)) |
895 | { | 930 | { |
896 | if (VolumesSizes.Size() == 0) | 931 | if (VolumesSizes.Size() == 0) |
897 | return S_FALSE; | 932 | return S_FALSE; |
@@ -901,7 +936,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size) | |||
901 | return S_OK; | 936 | return S_OK; |
902 | } | 937 | } |
903 | 938 | ||
904 | STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream) | 939 | Z7_COM7F_IMF(CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)) |
905 | { | 940 | { |
906 | COM_TRY_BEGIN | 941 | COM_TRY_BEGIN |
907 | char temp[16]; | 942 | char temp[16]; |
@@ -910,7 +945,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu | |||
910 | while (res.Len() < 2) | 945 | while (res.Len() < 2) |
911 | res.InsertAtFront(FTEXT('0')); | 946 | res.InsertAtFront(FTEXT('0')); |
912 | FString fileName = VolName; | 947 | FString fileName = VolName; |
913 | fileName += '.'; | 948 | fileName.Add_Dot(); |
914 | fileName += res; | 949 | fileName += res; |
915 | fileName += VolExt; | 950 | fileName += VolExt; |
916 | COutFileStream *streamSpec = new COutFileStream; | 951 | COutFileStream *streamSpec = new COutFileStream; |
@@ -922,14 +957,14 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu | |||
922 | COM_TRY_END | 957 | COM_TRY_END |
923 | } | 958 | } |
924 | 959 | ||
925 | STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) | 960 | Z7_COM7F_IMF(CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)) |
926 | { | 961 | { |
927 | COM_TRY_BEGIN | 962 | COM_TRY_BEGIN |
928 | return Callback->CryptoGetTextPassword2(passwordIsDefined, password); | 963 | return Callback->CryptoGetTextPassword2(passwordIsDefined, password); |
929 | COM_TRY_END | 964 | COM_TRY_END |
930 | } | 965 | } |
931 | 966 | ||
932 | STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword(BSTR *password) | 967 | Z7_COM7F_IMF(CArchiveUpdateCallback::CryptoGetTextPassword(BSTR *password)) |
933 | { | 968 | { |
934 | COM_TRY_BEGIN | 969 | COM_TRY_BEGIN |
935 | return Callback->CryptoGetTextPassword(password); | 970 | return Callback->CryptoGetTextPassword(password); |
@@ -949,7 +984,7 @@ HRESULT CArchiveUpdateCallback::InFileStream_On_Error(UINT_PTR val, DWORD error) | |||
949 | { | 984 | { |
950 | if (_openFiles_Indexes[i] == index) | 985 | if (_openFiles_Indexes[i] == index) |
951 | { | 986 | { |
952 | RINOK(Callback->ReadingFileError(_openFiles_Paths[i], error)); | 987 | RINOK(Callback->ReadingFileError(_openFiles_Paths[i], error)) |
953 | break; | 988 | break; |
954 | } | 989 | } |
955 | } | 990 | } |
diff --git a/CPP/7zip/UI/Common/UpdateCallback.h b/CPP/7zip/UI/Common/UpdateCallback.h index 3719c1e..379b814 100644 --- a/CPP/7zip/UI/Common/UpdateCallback.h +++ b/CPP/7zip/UI/Common/UpdateCallback.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // UpdateCallback.h | 1 | // UpdateCallback.h |
2 | 2 | ||
3 | #ifndef __UPDATE_CALLBACK_H | 3 | #ifndef ZIP7_INC_UPDATE_CALLBACK_H |
4 | #define __UPDATE_CALLBACK_H | 4 | #define ZIP7_INC_UPDATE_CALLBACK_H |
5 | 5 | ||
6 | #include "../../../Common/MyCom.h" | 6 | #include "../../../Common/MyCom.h" |
7 | 7 | ||
@@ -27,37 +27,38 @@ struct CArcToDoStat | |||
27 | } | 27 | } |
28 | }; | 28 | }; |
29 | 29 | ||
30 | #define INTERFACE_IUpdateCallbackUI(x) \ | 30 | |
31 | virtual HRESULT WriteSfx(const wchar_t *name, UInt64 size) x; \ | 31 | Z7_PURE_INTERFACES_BEGIN |
32 | virtual HRESULT SetTotal(UInt64 size) x; \ | 32 | |
33 | virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \ | 33 | #define Z7_IFACEN_IUpdateCallbackUI(x) \ |
34 | virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \ | 34 | virtual HRESULT WriteSfx(const wchar_t *name, UInt64 size) x \ |
35 | virtual HRESULT CheckBreak() x; \ | 35 | virtual HRESULT SetTotal(UInt64 size) x \ |
36 | /* virtual HRESULT Finalize() x; */ \ | 36 | virtual HRESULT SetCompleted(const UInt64 *completeValue) x \ |
37 | virtual HRESULT SetNumItems(const CArcToDoStat &stat) x; \ | 37 | virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x \ |
38 | virtual HRESULT GetStream(const wchar_t *name, bool isDir, bool isAnti, UInt32 mode) x; \ | 38 | virtual HRESULT CheckBreak() x \ |
39 | virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x; \ | 39 | /* virtual HRESULT Finalize() x */ \ |
40 | virtual HRESULT ReadingFileError(const FString &path, DWORD systemError) x; \ | 40 | virtual HRESULT SetNumItems(const CArcToDoStat &stat) x \ |
41 | virtual HRESULT SetOperationResult(Int32 opRes) x; \ | 41 | virtual HRESULT GetStream(const wchar_t *name, bool isDir, bool isAnti, UInt32 mode) x \ |
42 | virtual HRESULT ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name) x; \ | 42 | virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x \ |
43 | virtual HRESULT ReportUpdateOperation(UInt32 op, const wchar_t *name, bool isDir) x; \ | 43 | virtual HRESULT ReadingFileError(const FString &path, DWORD systemError) x \ |
44 | /* virtual HRESULT SetPassword(const UString &password) x; */ \ | 44 | virtual HRESULT SetOperationResult(Int32 opRes) x \ |
45 | virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \ | 45 | virtual HRESULT ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name) x \ |
46 | virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \ | 46 | virtual HRESULT ReportUpdateOperation(UInt32 op, const wchar_t *name, bool isDir) x \ |
47 | virtual HRESULT ShowDeleteFile(const wchar_t *name, bool isDir) x; \ | 47 | /* virtual HRESULT SetPassword(const UString &password) x */ \ |
48 | virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x \ | ||
49 | virtual HRESULT CryptoGetTextPassword(BSTR *password) x \ | ||
50 | virtual HRESULT ShowDeleteFile(const wchar_t *name, bool isDir) x \ | ||
48 | 51 | ||
49 | /* | 52 | /* |
50 | virtual HRESULT ReportProp(UInt32 indexType, UInt32 index, PROPID propID, const PROPVARIANT *value) x; \ | 53 | virtual HRESULT ReportProp(UInt32 indexType, UInt32 index, PROPID propID, const PROPVARIANT *value) x \ |
51 | virtual HRESULT ReportRawProp(UInt32 indexType, UInt32 index, PROPID propID, const void *data, UInt32 dataSize, UInt32 propType) x; \ | 54 | virtual HRESULT ReportRawProp(UInt32 indexType, UInt32 index, PROPID propID, const void *data, UInt32 dataSize, UInt32 propType) x \ |
52 | virtual HRESULT ReportFinished(UInt32 indexType, UInt32 index, Int32 opRes) x; \ | 55 | virtual HRESULT ReportFinished(UInt32 indexType, UInt32 index, Int32 opRes) x \ |
53 | */ | 56 | */ |
54 | 57 | ||
55 | /* virtual HRESULT CloseProgress() { return S_OK; } */ | 58 | /* virtual HRESULT CloseProgress() { return S_OK; } */ |
56 | 59 | ||
57 | struct IUpdateCallbackUI | 60 | Z7_IFACE_DECL_PURE(IUpdateCallbackUI) |
58 | { | 61 | Z7_PURE_INTERFACES_END |
59 | INTERFACE_IUpdateCallbackUI(=0) | ||
60 | }; | ||
61 | 62 | ||
62 | struct CKeyKeyValPair | 63 | struct CKeyKeyValPair |
63 | { | 64 | { |
@@ -74,11 +75,11 @@ struct CKeyKeyValPair | |||
74 | }; | 75 | }; |
75 | 76 | ||
76 | 77 | ||
77 | class CArchiveUpdateCallback: | 78 | class CArchiveUpdateCallback Z7_final: |
78 | public IArchiveUpdateCallback2, | 79 | public IArchiveUpdateCallback2, |
79 | public IArchiveUpdateCallbackFile, | 80 | public IArchiveUpdateCallbackFile, |
80 | // public IArchiveUpdateCallbackArcProp, | 81 | // public IArchiveUpdateCallbackArcProp, |
81 | public IArchiveExtractCallbackMessage, | 82 | public IArchiveExtractCallbackMessage2, |
82 | public IArchiveGetRawProps, | 83 | public IArchiveGetRawProps, |
83 | public IArchiveGetRootProps, | 84 | public IArchiveGetRootProps, |
84 | public ICryptoGetTextPassword2, | 85 | public ICryptoGetTextPassword2, |
@@ -87,54 +88,63 @@ class CArchiveUpdateCallback: | |||
87 | public IInFileStream_Callback, | 88 | public IInFileStream_Callback, |
88 | public CMyUnknownImp | 89 | public CMyUnknownImp |
89 | { | 90 | { |
90 | #if defined(_WIN32) && !defined(UNDER_CE) | 91 | Z7_COM_QI_BEGIN2(IArchiveUpdateCallback2) |
91 | bool _saclEnabled; | 92 | Z7_COM_QI_ENTRY(IArchiveUpdateCallbackFile) |
92 | #endif | 93 | // Z7_COM_QI_ENTRY(IArchiveUpdateCallbackArcProp) |
93 | CRecordVector<CKeyKeyValPair> _map; | 94 | Z7_COM_QI_ENTRY(IArchiveExtractCallbackMessage2) |
95 | Z7_COM_QI_ENTRY(IArchiveGetRawProps) | ||
96 | Z7_COM_QI_ENTRY(IArchiveGetRootProps) | ||
97 | Z7_COM_QI_ENTRY(ICryptoGetTextPassword2) | ||
98 | Z7_COM_QI_ENTRY(ICryptoGetTextPassword) | ||
99 | Z7_COM_QI_ENTRY(ICompressProgressInfo) | ||
100 | Z7_COM_QI_END | ||
101 | Z7_COM_ADDREF_RELEASE | ||
102 | |||
103 | Z7_IFACE_COM7_IMP(ICompressProgressInfo) | ||
104 | |||
105 | Z7_IFACE_COM7_IMP(IProgress) | ||
106 | Z7_IFACE_COM7_IMP(IArchiveUpdateCallback) | ||
107 | Z7_IFACE_COM7_IMP(IArchiveUpdateCallback2) | ||
108 | Z7_IFACE_COM7_IMP(IArchiveUpdateCallbackFile) | ||
109 | // Z7_IFACE_COM7_IMP(IArchiveUpdateCallbackArcProp) | ||
110 | Z7_IFACE_COM7_IMP(IArchiveExtractCallbackMessage2) | ||
111 | Z7_IFACE_COM7_IMP(IArchiveGetRawProps) | ||
112 | Z7_IFACE_COM7_IMP(IArchiveGetRootProps) | ||
113 | Z7_IFACE_COM7_IMP(ICryptoGetTextPassword2) | ||
114 | Z7_IFACE_COM7_IMP(ICryptoGetTextPassword) | ||
94 | 115 | ||
95 | UInt32 _hardIndex_From; | ||
96 | UInt32 _hardIndex_To; | ||
97 | 116 | ||
98 | void UpdateProcessedItemStatus(unsigned dirIndex); | 117 | void UpdateProcessedItemStatus(unsigned dirIndex); |
99 | 118 | ||
100 | public: | 119 | public: |
101 | MY_QUERYINTERFACE_BEGIN2(IArchiveUpdateCallback2) | 120 | bool PreserveATime; |
102 | MY_QUERYINTERFACE_ENTRY(IArchiveUpdateCallbackFile) | 121 | bool ShareForWrite; |
103 | // MY_QUERYINTERFACE_ENTRY(IArchiveUpdateCallbackArcProp) | 122 | bool StopAfterOpenError; |
104 | MY_QUERYINTERFACE_ENTRY(IArchiveExtractCallbackMessage) | 123 | bool StdInMode; |
105 | MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps) | 124 | |
106 | MY_QUERYINTERFACE_ENTRY(IArchiveGetRootProps) | 125 | bool KeepOriginalItemNames; |
107 | MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword2) | 126 | bool StoreNtSecurity; |
108 | MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword) | 127 | bool StoreHardLinks; |
109 | MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo) | 128 | bool StoreSymLinks; |
110 | MY_QUERYINTERFACE_END | 129 | |
111 | MY_ADDREF_RELEASE | 130 | bool StoreOwnerId; |
112 | 131 | bool StoreOwnerName; | |
113 | 132 | ||
114 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); | 133 | bool Need_LatestMTime; |
115 | 134 | bool LatestMTime_Defined; | |
116 | INTERFACE_IArchiveUpdateCallback2(;) | 135 | |
117 | INTERFACE_IArchiveUpdateCallbackFile(;) | 136 | /* |
118 | // INTERFACE_IArchiveUpdateCallbackArcProp(;) | 137 | bool Need_ArcMTime_Report; |
119 | INTERFACE_IArchiveExtractCallbackMessage(;) | 138 | bool ArcMTime_WasReported; |
120 | INTERFACE_IArchiveGetRawProps(;) | 139 | */ |
121 | INTERFACE_IArchiveGetRootProps(;) | ||
122 | |||
123 | STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password); | ||
124 | STDMETHOD(CryptoGetTextPassword)(BSTR *password); | ||
125 | 140 | ||
126 | CRecordVector<UInt32> _openFiles_Indexes; | 141 | CRecordVector<UInt32> _openFiles_Indexes; |
127 | FStringVector _openFiles_Paths; | 142 | FStringVector _openFiles_Paths; |
128 | // CRecordVector< CInFileStream* > _openFiles_Streams; | 143 | // CRecordVector< CInFileStream* > _openFiles_Streams; |
129 | 144 | ||
130 | bool AreAllFilesClosed() const { return _openFiles_Indexes.IsEmpty(); } | 145 | bool AreAllFilesClosed() const { return _openFiles_Indexes.IsEmpty(); } |
131 | virtual HRESULT InFileStream_On_Error(UINT_PTR val, DWORD error); | 146 | virtual HRESULT InFileStream_On_Error(UINT_PTR val, DWORD error) Z7_override; |
132 | virtual void InFileStream_On_Destroy(CInFileStream *stream, UINT_PTR val); | 147 | virtual void InFileStream_On_Destroy(CInFileStream *stream, UINT_PTR val) Z7_override; |
133 | |||
134 | CRecordVector<UInt64> VolumesSizes; | ||
135 | FString VolName; | ||
136 | FString VolExt; | ||
137 | UString ArcFileName; // without path prefix | ||
138 | 148 | ||
139 | IUpdateCallbackUI *Callback; | 149 | IUpdateCallbackUI *Callback; |
140 | 150 | ||
@@ -145,36 +155,24 @@ public: | |||
145 | CMyComPtr<IInArchive> Archive; | 155 | CMyComPtr<IInArchive> Archive; |
146 | const CObjectVector<CArcItem> *ArcItems; | 156 | const CObjectVector<CArcItem> *ArcItems; |
147 | const CRecordVector<CUpdatePair2> *UpdatePairs; | 157 | const CRecordVector<CUpdatePair2> *UpdatePairs; |
148 | const UStringVector *NewNames; | ||
149 | int CommentIndex; | ||
150 | const UString *Comment; | ||
151 | 158 | ||
152 | bool PreserveATime; | 159 | CRecordVector<UInt64> VolumesSizes; |
153 | bool ShareForWrite; | 160 | FString VolName; |
154 | bool StopAfterOpenError; | 161 | FString VolExt; |
155 | bool StdInMode; | 162 | UString ArcFileName; // without path prefix |
156 | |||
157 | bool KeepOriginalItemNames; | ||
158 | bool StoreNtSecurity; | ||
159 | bool StoreHardLinks; | ||
160 | bool StoreSymLinks; | ||
161 | 163 | ||
162 | bool StoreOwnerId; | 164 | const UStringVector *NewNames; |
163 | bool StoreOwnerName; | 165 | const UString *Comment; |
166 | int CommentIndex; | ||
164 | 167 | ||
165 | /* | 168 | /* |
166 | bool Need_ArcMTime_Report; | ||
167 | bool ArcMTime_WasReported; | ||
168 | CArcTime Reported_ArcMTime; | 169 | CArcTime Reported_ArcMTime; |
169 | */ | 170 | */ |
170 | bool Need_LatestMTime; | ||
171 | bool LatestMTime_Defined; | ||
172 | CFiTime LatestMTime; | 171 | CFiTime LatestMTime; |
173 | 172 | ||
174 | Byte *ProcessedItemsStatuses; | 173 | Byte *ProcessedItemsStatuses; |
175 | 174 | ||
176 | 175 | ||
177 | |||
178 | CArchiveUpdateCallback(); | 176 | CArchiveUpdateCallback(); |
179 | 177 | ||
180 | bool IsDir(const CUpdatePair2 &up) const | 178 | bool IsDir(const CUpdatePair2 &up) const |
@@ -185,6 +183,15 @@ public: | |||
185 | return (*ArcItems)[(unsigned)up.ArcIndex].IsDir; | 183 | return (*ArcItems)[(unsigned)up.ArcIndex].IsDir; |
186 | return false; | 184 | return false; |
187 | } | 185 | } |
186 | |||
187 | private: | ||
188 | #if defined(_WIN32) && !defined(UNDER_CE) | ||
189 | bool _saclEnabled; | ||
190 | #endif | ||
191 | CRecordVector<CKeyKeyValPair> _map; | ||
192 | |||
193 | UInt32 _hardIndex_From; | ||
194 | UInt32 _hardIndex_To; | ||
188 | }; | 195 | }; |
189 | 196 | ||
190 | #endif | 197 | #endif |
diff --git a/CPP/7zip/UI/Common/UpdatePair.cpp b/CPP/7zip/UI/Common/UpdatePair.cpp index e9a1644..99b0aaf 100644 --- a/CPP/7zip/UI/Common/UpdatePair.cpp +++ b/CPP/7zip/UI/Common/UpdatePair.cpp | |||
@@ -103,7 +103,7 @@ static const char * const k_Duplicate_inArc_Message = "Duplicate filename in arc | |||
103 | static const char * const k_Duplicate_inDir_Message = "Duplicate filename on disk:"; | 103 | static const char * const k_Duplicate_inDir_Message = "Duplicate filename on disk:"; |
104 | static const char * const k_NotCensoredCollision_Message = "Internal file name collision (file on disk, file in archive):"; | 104 | static const char * const k_NotCensoredCollision_Message = "Internal file name collision (file on disk, file in archive):"; |
105 | 105 | ||
106 | MY_ATTR_NORETURN | 106 | Z7_ATTR_NORETURN |
107 | static | 107 | static |
108 | void ThrowError(const char *message, const UString &s1, const UString &s2) | 108 | void ThrowError(const char *message, const UString &s1, const UString &s2) |
109 | { | 109 | { |
@@ -115,7 +115,7 @@ void ThrowError(const char *message, const UString &s1, const UString &s2) | |||
115 | 115 | ||
116 | static int CompareArcItemsBase(const CArcItem &ai1, const CArcItem &ai2) | 116 | static int CompareArcItemsBase(const CArcItem &ai1, const CArcItem &ai2) |
117 | { | 117 | { |
118 | int res = CompareFileNames(ai1.Name, ai2.Name); | 118 | const int res = CompareFileNames(ai1.Name, ai2.Name); |
119 | if (res != 0) | 119 | if (res != 0) |
120 | return res; | 120 | return res; |
121 | if (ai1.IsDir != ai2.IsDir) | 121 | if (ai1.IsDir != ai2.IsDir) |
@@ -128,7 +128,7 @@ static int CompareArcItems(const unsigned *p1, const unsigned *p2, void *param) | |||
128 | const unsigned i1 = *p1; | 128 | const unsigned i1 = *p1; |
129 | const unsigned i2 = *p2; | 129 | const unsigned i2 = *p2; |
130 | const CObjectVector<CArcItem> &arcItems = *(const CObjectVector<CArcItem> *)param; | 130 | const CObjectVector<CArcItem> &arcItems = *(const CObjectVector<CArcItem> *)param; |
131 | int res = CompareArcItemsBase(arcItems[i1], arcItems[i2]); | 131 | const int res = CompareArcItemsBase(arcItems[i1], arcItems[i2]); |
132 | if (res != 0) | 132 | if (res != 0) |
133 | return res; | 133 | return res; |
134 | return MyCompare(i1, i2); | 134 | return MyCompare(i1, i2); |
@@ -259,7 +259,7 @@ void GetUpdatePairInfoList( | |||
259 | int compResult = 0; | 259 | int compResult = 0; |
260 | if (ai->MTime.Def) | 260 | if (ai->MTime.Def) |
261 | { | 261 | { |
262 | compResult = MyCompareTime(fileTimeType, di->MTime, ai->MTime); | 262 | compResult = MyCompareTime((unsigned)fileTimeType, di->MTime, ai->MTime); |
263 | } | 263 | } |
264 | switch (compResult) | 264 | switch (compResult) |
265 | { | 265 | { |
@@ -283,7 +283,7 @@ void GetUpdatePairInfoList( | |||
283 | { | 283 | { |
284 | if (prevHostName) | 284 | if (prevHostName) |
285 | { | 285 | { |
286 | unsigned hostLen = prevHostName->Len(); | 286 | const unsigned hostLen = prevHostName->Len(); |
287 | if (name->Len() > hostLen) | 287 | if (name->Len() > hostLen) |
288 | if ((*name)[hostLen] == ':' && CompareFileNames(*prevHostName, name->Left(hostLen)) == 0) | 288 | if ((*name)[hostLen] == ':' && CompareFileNames(*prevHostName, name->Left(hostLen)) == 0) |
289 | pair.HostIndex = prevHostFile; | 289 | pair.HostIndex = prevHostFile; |
diff --git a/CPP/7zip/UI/Common/UpdatePair.h b/CPP/7zip/UI/Common/UpdatePair.h index 296d3b0..13228b0 100644 --- a/CPP/7zip/UI/Common/UpdatePair.h +++ b/CPP/7zip/UI/Common/UpdatePair.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // UpdatePair.h | 1 | // UpdatePair.h |
2 | 2 | ||
3 | #ifndef __UPDATE_PAIR_H | 3 | #ifndef ZIP7_INC_UPDATE_PAIR_H |
4 | #define __UPDATE_PAIR_H | 4 | #define ZIP7_INC_UPDATE_PAIR_H |
5 | 5 | ||
6 | #include "DirItem.h" | 6 | #include "DirItem.h" |
7 | #include "UpdateAction.h" | 7 | #include "UpdateAction.h" |
diff --git a/CPP/7zip/UI/Common/UpdateProduce.h b/CPP/7zip/UI/Common/UpdateProduce.h index 24bb32e..9db6c1e 100644 --- a/CPP/7zip/UI/Common/UpdateProduce.h +++ b/CPP/7zip/UI/Common/UpdateProduce.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // UpdateProduce.h | 1 | // UpdateProduce.h |
2 | 2 | ||
3 | #ifndef __UPDATE_PRODUCE_H | 3 | #ifndef ZIP7_INC_UPDATE_PRODUCE_H |
4 | #define __UPDATE_PRODUCE_H | 4 | #define ZIP7_INC_UPDATE_PRODUCE_H |
5 | 5 | ||
6 | #include "UpdatePair.h" | 6 | #include "UpdatePair.h" |
7 | 7 | ||
@@ -43,10 +43,13 @@ struct CUpdatePair2 | |||
43 | {} | 43 | {} |
44 | }; | 44 | }; |
45 | 45 | ||
46 | struct IUpdateProduceCallback | 46 | Z7_PURE_INTERFACES_BEGIN |
47 | |||
48 | DECLARE_INTERFACE(IUpdateProduceCallback) | ||
47 | { | 49 | { |
48 | virtual HRESULT ShowDeleteFile(unsigned arcIndex) = 0; | 50 | virtual HRESULT ShowDeleteFile(unsigned arcIndex) = 0; |
49 | }; | 51 | }; |
52 | Z7_PURE_INTERFACES_END | ||
50 | 53 | ||
51 | void UpdateProduce( | 54 | void UpdateProduce( |
52 | const CRecordVector<CUpdatePair> &updatePairs, | 55 | const CRecordVector<CUpdatePair> &updatePairs, |
diff --git a/CPP/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp index 1307cee..cfec635 100644 --- a/CPP/7zip/UI/Common/WorkDir.cpp +++ b/CPP/7zip/UI/Common/WorkDir.cpp | |||
@@ -2,11 +2,8 @@ | |||
2 | 2 | ||
3 | #include "StdAfx.h" | 3 | #include "StdAfx.h" |
4 | 4 | ||
5 | #include "../../../Common/StringConvert.h" | ||
6 | #include "../../../Common/Wildcard.h" | ||
7 | |||
8 | #include "../../../Windows/FileFind.h" | ||
9 | #include "../../../Windows/FileName.h" | 5 | #include "../../../Windows/FileName.h" |
6 | #include "../../../Windows/FileSystem.h" | ||
10 | 7 | ||
11 | #include "WorkDir.h" | 8 | #include "WorkDir.h" |
12 | 9 | ||
@@ -22,10 +19,10 @@ FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FStr | |||
22 | if (workDirInfo.ForRemovableOnly) | 19 | if (workDirInfo.ForRemovableOnly) |
23 | { | 20 | { |
24 | mode = NWorkDir::NMode::kCurrent; | 21 | mode = NWorkDir::NMode::kCurrent; |
25 | FString prefix = path.Left(3); | 22 | const FString prefix = path.Left(3); |
26 | if (prefix[1] == FTEXT(':') && prefix[2] == FTEXT('\\')) | 23 | if (NName::IsDrivePath(prefix)) |
27 | { | 24 | { |
28 | UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP)); | 25 | const UINT driveType = NSystem::MyGetDriveType(prefix); |
29 | if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) | 26 | if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) |
30 | mode = workDirInfo.Mode; | 27 | mode = workDirInfo.Mode; |
31 | } | 28 | } |
@@ -39,29 +36,26 @@ FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FStr | |||
39 | } | 36 | } |
40 | #endif | 37 | #endif |
41 | 38 | ||
42 | int pos = path.ReverseFind_PathSepar() + 1; | 39 | const int pos = path.ReverseFind_PathSepar() + 1; |
43 | fileName = path.Ptr((unsigned)pos); | 40 | fileName = path.Ptr((unsigned)pos); |
44 | 41 | ||
45 | switch (mode) | 42 | FString tempDir; |
43 | switch ((int)mode) | ||
46 | { | 44 | { |
47 | case NWorkDir::NMode::kCurrent: | 45 | case NWorkDir::NMode::kCurrent: |
48 | { | 46 | tempDir = path.Left((unsigned)pos); |
49 | return path.Left((unsigned)pos); | 47 | break; |
50 | } | ||
51 | case NWorkDir::NMode::kSpecified: | 48 | case NWorkDir::NMode::kSpecified: |
52 | { | 49 | tempDir = workDirInfo.Path; |
53 | FString tempDir = workDirInfo.Path; | 50 | break; |
54 | NName::NormalizeDirPathPrefix(tempDir); | 51 | // case NWorkDir::NMode::kSystem: |
55 | return tempDir; | ||
56 | } | ||
57 | default: | 52 | default: |
58 | { | ||
59 | FString tempDir; | ||
60 | if (!MyGetTempPath(tempDir)) | 53 | if (!MyGetTempPath(tempDir)) |
61 | throw 141717; | 54 | throw 141717; |
62 | return tempDir; | 55 | break; |
63 | } | ||
64 | } | 56 | } |
57 | NName::NormalizeDirPathPrefix(tempDir); | ||
58 | return tempDir; | ||
65 | } | 59 | } |
66 | 60 | ||
67 | HRESULT CWorkDirTempFile::CreateTempFile(const FString &originalPath) | 61 | HRESULT CWorkDirTempFile::CreateTempFile(const FString &originalPath) |
@@ -69,9 +63,8 @@ HRESULT CWorkDirTempFile::CreateTempFile(const FString &originalPath) | |||
69 | NWorkDir::CInfo workDirInfo; | 63 | NWorkDir::CInfo workDirInfo; |
70 | workDirInfo.Load(); | 64 | workDirInfo.Load(); |
71 | FString namePart; | 65 | FString namePart; |
72 | FString workDir = GetWorkDir(workDirInfo, originalPath, namePart); | 66 | const FString workDir = GetWorkDir(workDirInfo, originalPath, namePart); |
73 | CreateComplexDir(workDir); | 67 | CreateComplexDir(workDir); |
74 | CTempFile tempFile; | ||
75 | _outStreamSpec = new COutFileStream; | 68 | _outStreamSpec = new COutFileStream; |
76 | OutStream = _outStreamSpec; | 69 | OutStream = _outStreamSpec; |
77 | if (!_tempFile.Create(workDir + namePart, &_outStreamSpec->File)) | 70 | if (!_tempFile.Create(workDir + namePart, &_outStreamSpec->File)) |
diff --git a/CPP/7zip/UI/Common/WorkDir.h b/CPP/7zip/UI/Common/WorkDir.h index 75850a9..d32ab9d 100644 --- a/CPP/7zip/UI/Common/WorkDir.h +++ b/CPP/7zip/UI/Common/WorkDir.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // WorkDir.h | 1 | // WorkDir.h |
2 | 2 | ||
3 | #ifndef __WORK_DIR_H | 3 | #ifndef ZIP7_INC_WORK_DIR_H |
4 | #define __WORK_DIR_H | 4 | #define ZIP7_INC_WORK_DIR_H |
5 | 5 | ||
6 | #include "../../../Windows/FileDir.h" | 6 | #include "../../../Windows/FileDir.h" |
7 | 7 | ||
diff --git a/CPP/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp index a67a99b..6c1b9c8 100644 --- a/CPP/7zip/UI/Common/ZipRegistry.cpp +++ b/CPP/7zip/UI/Common/ZipRegistry.cpp | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "../../../Windows/Registry.h" | 11 | #include "../../../Windows/Registry.h" |
12 | #include "../../../Windows/Synchronization.h" | 12 | #include "../../../Windows/Synchronization.h" |
13 | 13 | ||
14 | // #include "../Explorer/ContextMenuFlags.h" | ||
14 | #include "ZipRegistry.h" | 15 | #include "ZipRegistry.h" |
15 | 16 | ||
16 | using namespace NWindows; | 17 | using namespace NWindows; |
@@ -191,6 +192,7 @@ static LPCTSTR const kOptionsKeyName = TEXT("Options"); | |||
191 | 192 | ||
192 | static LPCTSTR const kLevel = TEXT("Level"); | 193 | static LPCTSTR const kLevel = TEXT("Level"); |
193 | static LPCTSTR const kDictionary = TEXT("Dictionary"); | 194 | static LPCTSTR const kDictionary = TEXT("Dictionary"); |
195 | // static LPCTSTR const kDictionaryChain = TEXT("DictionaryChain"); | ||
194 | static LPCTSTR const kOrder = TEXT("Order"); | 196 | static LPCTSTR const kOrder = TEXT("Order"); |
195 | static LPCTSTR const kBlockSize = TEXT("BlockSize"); | 197 | static LPCTSTR const kBlockSize = TEXT("BlockSize"); |
196 | static LPCTSTR const kNumThreads = TEXT("NumThreads"); | 198 | static LPCTSTR const kNumThreads = TEXT("NumThreads"); |
@@ -269,6 +271,7 @@ void CInfo::Save() const | |||
269 | 271 | ||
270 | Key_Set_UInt32(fk, kLevel, fo.Level); | 272 | Key_Set_UInt32(fk, kLevel, fo.Level); |
271 | Key_Set_UInt32(fk, kDictionary, fo.Dictionary); | 273 | Key_Set_UInt32(fk, kDictionary, fo.Dictionary); |
274 | // Key_Set_UInt32(fk, kDictionaryChain, fo.DictionaryChain); | ||
272 | Key_Set_UInt32(fk, kOrder, fo.Order); | 275 | Key_Set_UInt32(fk, kOrder, fo.Order); |
273 | Key_Set_UInt32(fk, kBlockSize, fo.BlockLogSize); | 276 | Key_Set_UInt32(fk, kBlockSize, fo.BlockLogSize); |
274 | Key_Set_UInt32(fk, kNumThreads, fo.NumThreads); | 277 | Key_Set_UInt32(fk, kNumThreads, fo.NumThreads); |
@@ -326,6 +329,7 @@ void CInfo::Load() | |||
326 | 329 | ||
327 | Key_Get_UInt32(fk, kLevel, fo.Level); | 330 | Key_Get_UInt32(fk, kLevel, fo.Level); |
328 | Key_Get_UInt32(fk, kDictionary, fo.Dictionary); | 331 | Key_Get_UInt32(fk, kDictionary, fo.Dictionary); |
332 | // Key_Get_UInt32(fk, kDictionaryChain, fo.DictionaryChain); | ||
329 | Key_Get_UInt32(fk, kOrder, fo.Order); | 333 | Key_Get_UInt32(fk, kOrder, fo.Order); |
330 | Key_Get_UInt32(fk, kBlockSize, fo.BlockLogSize); | 334 | Key_Get_UInt32(fk, kBlockSize, fo.BlockLogSize); |
331 | Key_Get_UInt32(fk, kNumThreads, fo.NumThreads); | 335 | Key_Get_UInt32(fk, kNumThreads, fo.NumThreads); |
@@ -549,7 +553,15 @@ void CContextMenuInfo::Load() | |||
549 | 553 | ||
550 | WriteZone = (UInt32)(Int32)-1; | 554 | WriteZone = (UInt32)(Int32)-1; |
551 | 555 | ||
552 | Flags = (UInt32)(Int32)-1; | 556 | /* we can disable email items by default, |
557 | because email code doesn't work in some systems */ | ||
558 | Flags = (UInt32)(Int32)-1 | ||
559 | /* | ||
560 | & ~NContextMenuFlags::kCompressEmail | ||
561 | & ~NContextMenuFlags::kCompressTo7zEmail | ||
562 | & ~NContextMenuFlags::kCompressToZipEmail | ||
563 | */ | ||
564 | ; | ||
553 | Flags_Def = false; | 565 | Flags_Def = false; |
554 | 566 | ||
555 | CS_LOCK | 567 | CS_LOCK |
diff --git a/CPP/7zip/UI/Common/ZipRegistry.h b/CPP/7zip/UI/Common/ZipRegistry.h index b7075e6..6bc6977 100644 --- a/CPP/7zip/UI/Common/ZipRegistry.h +++ b/CPP/7zip/UI/Common/ZipRegistry.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // ZipRegistry.h | 1 | // ZipRegistry.h |
2 | 2 | ||
3 | #ifndef __ZIP_REGISTRY_H | 3 | #ifndef ZIP7_INC_ZIP_REGISTRY_H |
4 | #define __ZIP_REGISTRY_H | 4 | #define ZIP7_INC_ZIP_REGISTRY_H |
5 | 5 | ||
6 | #include "../../../Common/MyTypes.h" | 6 | #include "../../../Common/MyTypes.h" |
7 | #include "../../../Common/MyString.h" | 7 | #include "../../../Common/MyString.h" |
@@ -81,6 +81,7 @@ namespace NCompression | |||
81 | { | 81 | { |
82 | UInt32 Level; | 82 | UInt32 Level; |
83 | UInt32 Dictionary; | 83 | UInt32 Dictionary; |
84 | // UInt32 DictionaryChain; | ||
84 | UInt32 Order; | 85 | UInt32 Order; |
85 | UInt32 BlockLogSize; | 86 | UInt32 BlockLogSize; |
86 | UInt32 NumThreads; | 87 | UInt32 NumThreads; |
@@ -116,6 +117,7 @@ namespace NCompression | |||
116 | void ResetForLevelChange() | 117 | void ResetForLevelChange() |
117 | { | 118 | { |
118 | BlockLogSize = NumThreads = Level = Dictionary = Order = (UInt32)(Int32)-1; | 119 | BlockLogSize = NumThreads = Level = Dictionary = Order = (UInt32)(Int32)-1; |
120 | // DictionaryChain = (UInt32)(Int32)-1; | ||
119 | Method.Empty(); | 121 | Method.Empty(); |
120 | // Options.Empty(); | 122 | // Options.Empty(); |
121 | // EncryptionMethod.Empty(); | 123 | // EncryptionMethod.Empty(); |
@@ -133,10 +135,6 @@ namespace NCompression | |||
133 | UInt32 Level; | 135 | UInt32 Level; |
134 | bool ShowPassword; | 136 | bool ShowPassword; |
135 | bool EncryptHeaders; | 137 | bool EncryptHeaders; |
136 | UString ArcType; | ||
137 | UStringVector ArcPaths; | ||
138 | |||
139 | CObjectVector<CFormatOptions> Formats; | ||
140 | 138 | ||
141 | CBoolPair NtSecurity; | 139 | CBoolPair NtSecurity; |
142 | CBoolPair AltStreams; | 140 | CBoolPair AltStreams; |
@@ -145,6 +143,11 @@ namespace NCompression | |||
145 | 143 | ||
146 | CBoolPair PreserveATime; | 144 | CBoolPair PreserveATime; |
147 | 145 | ||
146 | UString ArcType; | ||
147 | UStringVector ArcPaths; | ||
148 | |||
149 | CObjectVector<CFormatOptions> Formats; | ||
150 | |||
148 | void Save() const; | 151 | void Save() const; |
149 | void Load(); | 152 | void Load(); |
150 | }; | 153 | }; |
@@ -164,8 +167,8 @@ namespace NWorkDir | |||
164 | struct CInfo | 167 | struct CInfo |
165 | { | 168 | { |
166 | NMode::EEnum Mode; | 169 | NMode::EEnum Mode; |
167 | FString Path; | ||
168 | bool ForRemovableOnly; | 170 | bool ForRemovableOnly; |
171 | FString Path; | ||
169 | 172 | ||
170 | void SetForRemovableOnlyDefault() { ForRemovableOnly = true; } | 173 | void SetForRemovableOnlyDefault() { ForRemovableOnly = true; } |
171 | void SetDefault() | 174 | void SetDefault() |