Skip to content

Commit 39c8aa7

Browse files
committed
fix extraction of multiple archives using smart directory creation
1 parent cbdf018 commit 39c8aa7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

RootHelper/archiveOps.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ that is, files or folders themselves without their sub-tree nodes)
275275
all the entries of its subtree (the entire archive content tree has already been stored in a VMap on archive open for listing)
276276
- if items are not top-level in the archive, the path truncation offset is needed in order to perform natural relative extraction
277277
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
279279
*/
280280
void extractFromArchive(IDescriptor& inOutDesc, const uint8_t flags)
281281
{
@@ -316,16 +316,17 @@ void extractFromArchive(IDescriptor& inOutDesc, const uint8_t flags)
316316
PRINTUNIFIED("received destination folder path is:\t%s\n", destFolder.c_str());
317317
}
318318

319-
bool testMode = destFolder.empty();
319+
const bool testMode = destFolder.empty();
320320

321321
// 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
323324

324325
// read number of entries to be received; 0 means "extract all content from archive"
325326
uint32_t nOfEntriesToExtract, i;
326327
inOutDesc.readAllOrExit( &(nOfEntriesToExtract), sizeof(uint32_t));
327328

328-
bool smartCreateDirectory = (!b0(flags)) && (nOfEntriesToExtract == 0) && !testMode;
329+
const bool smartCreateDirectory = (!b0(flags)) && (nOfEntriesToExtract == 0) && !testMode;
329330

330331
std::vector<uint32_t> currentEntries;
331332

@@ -354,7 +355,7 @@ void extractFromArchive(IDescriptor& inOutDesc, const uint8_t flags)
354355
inOutDesc.readAllOrExit(&subDirLengthForPathTruncateInWideChars,sizeof(uint32_t));
355356
}
356357

357-
for(auto& srcArchive : f) {
358+
for(const auto& srcArchive : f) {
358359

359360
auto&& srcArchive_ = UTF8_to_wchar(srcArchive);
360361
FString archiveName(srcArchive_.c_str());
@@ -453,6 +454,8 @@ void extractFromArchive(IDescriptor& inOutDesc, const uint8_t flags)
453454
extractCallbackSpec->PasswordIsDefined = (!password.empty());
454455
extractCallbackSpec->Password = FString(password_.c_str());
455456

457+
if(smartCreateDirectory) destFolder = dstFolderBackup; // restore old value after having modified it in the current iteration
458+
456459
HRESULT result;
457460

458461
if (currentEntries.empty())

RootHelper/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "unifiedlogging.h"
55

6-
const char* _ROOTHELPER_VERSION_ = "1.8.0_20201227";
6+
const char* _ROOTHELPER_VERSION_ = "1.8.0_20201229";
77

88
inline void print_roothelper_version() {
99
PRINTUNIFIED("Roothelper version %s\n",_ROOTHELPER_VERSION_);

0 commit comments

Comments
 (0)