Fix regex file names in extract

~~this code kinda sucks and should be redone~~
This commit is contained in:
Epicpkmn11 2019-11-10 13:06:17 -06:00
commit 955b644ad4

View file

@ -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;