Fix regex file names in extract
~~this code kinda sucks and should be redone~~
This commit is contained in:
parent
08b962b560
commit
955b644ad4
1 changed files with 6 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue