From 955b644ad482845225a7ea54ee78ec8d04ef6460 Mon Sep 17 00:00:00 2001 From: Epicpkmn11 Date: Sun, 10 Nov 2019 13:06:17 -0600 Subject: [PATCH] Fix regex file names in extract ~~this code kinda sucks and should be redone~~ --- source/utils/extract.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/utils/extract.cpp b/source/utils/extract.cpp index 0ee81cd..08cead4 100644 --- a/source/utils/extract.cpp +++ b/source/utils/extract.cpp @@ -51,15 +51,17 @@ Result extractArchive(std::string archivePath, std::string wantedFile, std::stri while (archive_read_next_header(a, &entry) == ARCHIVE_OK) { std::string entryName(archive_entry_pathname(entry)); if (wantedFile == "/") wantedFile = ""; - if (matchPattern(wantedFile, entryName.substr(0,wantedFile.length())) || wantedFile == "") { + if (matchPattern(wantedFile, entryName) || matchPattern(wantedFile, entryName.substr(0, wantedFile.size())) || wantedFile == "") { extractingFile = (entryName.length() > wantedFile.length() ? entryName.substr(wantedFile.length()) : wantedFile); ret = EXTRACT_ERROR_NONE; Handle fileHandle; std::string outputPathFinal = outputPath; - if (entryName.length() > wantedFile.length()) - outputPathFinal += entryName.substr(wantedFile.length()); - if (outputPathFinal.substr(outputPathFinal.length()-1) == "/") continue; + if(wantedFile[wantedFile.length()-1] == '/') { // Folder + if (entryName.length() > wantedFile.length()) + outputPathFinal += entryName.substr(wantedFile.length()); + if (outputPathFinal.substr(outputPathFinal.length()-1) == "/") continue; + } Result res = openFile(&fileHandle, outputPathFinal.c_str(), true); if (R_FAILED(res)) { ret = EXTRACT_ERROR_OPENFILE;