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;