@@ -275,7 +275,7 @@ that is, files or folders themselves without their sub-tree nodes)
275
275
all the entries of its subtree (the entire archive content tree has already been stored in a VMap on archive open for listing)
276
276
- if items are not top-level in the archive, the path truncation offset is needed in order to perform natural relative extraction
277
277
278
- if flags == 6 (binary: 110 ), internally call list archive with the same flag in order to determine whether to create or not an intermediate directory
278
+ if b0( flags) (binary: xx0 ), internally call list archive with the same flag in order to determine whether to create or not an intermediate directory
279
279
*/
280
280
void extractFromArchive (IDescriptor& inOutDesc, const uint8_t flags)
281
281
{
@@ -316,16 +316,17 @@ void extractFromArchive(IDescriptor& inOutDesc, const uint8_t flags)
316
316
PRINTUNIFIED (" received destination folder path is:\t %s\n " , destFolder.c_str ());
317
317
}
318
318
319
- bool testMode = destFolder.empty ();
319
+ const bool testMode = destFolder.empty ();
320
320
321
321
// read password, if provided
322
- std::string password = readStringWithByteLen (inOutDesc);
322
+ const std::string password = readStringWithByteLen (inOutDesc);
323
+ const std::string dstFolderBackup = destFolder; // for smart create directory mode
323
324
324
325
// read number of entries to be received; 0 means "extract all content from archive"
325
326
uint32_t nOfEntriesToExtract, i;
326
327
inOutDesc.readAllOrExit ( &(nOfEntriesToExtract), sizeof (uint32_t ));
327
328
328
- bool smartCreateDirectory = (!b0 (flags)) && (nOfEntriesToExtract == 0 ) && !testMode;
329
+ const bool smartCreateDirectory = (!b0 (flags)) && (nOfEntriesToExtract == 0 ) && !testMode;
329
330
330
331
std::vector<uint32_t > currentEntries;
331
332
@@ -354,7 +355,7 @@ void extractFromArchive(IDescriptor& inOutDesc, const uint8_t flags)
354
355
inOutDesc.readAllOrExit (&subDirLengthForPathTruncateInWideChars,sizeof (uint32_t ));
355
356
}
356
357
357
- for (auto & srcArchive : f) {
358
+ for (const auto & srcArchive : f) {
358
359
359
360
auto && srcArchive_ = UTF8_to_wchar (srcArchive);
360
361
FString archiveName (srcArchive_.c_str ());
@@ -453,6 +454,8 @@ void extractFromArchive(IDescriptor& inOutDesc, const uint8_t flags)
453
454
extractCallbackSpec->PasswordIsDefined = (!password.empty ());
454
455
extractCallbackSpec->Password = FString (password_.c_str ());
455
456
457
+ if (smartCreateDirectory) destFolder = dstFolderBackup; // restore old value after having modified it in the current iteration
458
+
456
459
HRESULT result;
457
460
458
461
if (currentEntries.empty ())
0 commit comments