From 8e369d2d1fded963b2d4eb4f51ba8d46303fb4ea Mon Sep 17 00:00:00 2001 From: Pk11 Date: Fri, 30 Oct 2020 02:05:24 -0500 Subject: [PATCH] *actually* fix extraction directory making --- source/utils/extract.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/utils/extract.cpp b/source/utils/extract.cpp index 2a0390d..59817cd 100644 --- a/source/utils/extract.cpp +++ b/source/utils/extract.cpp @@ -37,7 +37,7 @@ std::string extractingFile = ""; u64 extractSize = 0, writeOffset = 0; Result getExtractedSize(const std::string &archivePath, const std::string &wantedFile) { - extractSize = 0, writeOffset = 0, filesExtracted = 0; + extractSize = 0, writeOffset = 0, filesExtracted = 0, extractFilesCount = 0; archive *a = archive_read_new(); archive_entry *entry; @@ -80,10 +80,13 @@ Result extractArchive(const std::string &archivePath, const std::string &wantedF extractingFile = outputPath + match.suffix().str(); /* make directories. */ - int substrPos = 1; - while(extractingFile.find("/", substrPos)) { - mkdir(extractingFile.substr(0, substrPos).c_str(), 0777); - substrPos = extractingFile.find("/", substrPos) + 1; + for (char *slashpos = strchr(extractingFile.c_str() + 1, '/'); slashpos != NULL; slashpos = strchr(slashpos + 1, '/')) { + char bak = *(slashpos); + *(slashpos) = '\0'; + + mkdir(extractingFile.c_str(), 0777); + + *(slashpos) = bak; } uint sizeLeft = archive_entry_size(entry);