Fix directory path when extracting from archive

* Don't create new dir in execution dir of melonds
* Create it beside the archive instead

Signed-off-by: Madhav Kanbur <abcdjdj@gmail.com>
This commit is contained in:
Madhav Kanbur
2021-01-08 16:20:57 +05:30
parent b402cb19b2
commit d673445d81

View File

@ -91,9 +91,10 @@ QVector<QString> ExtractFileFromArchive(const char* path, const char* wantedFile
archiveBuffer.reset(nullptr);
return QVector<QString> {"Err", archive_error_string(a)};
}
QString nameToWrite = QFileInfo(path).absolutePath() + "/" + QFileInfo(path).baseName() + "/" + archive_entry_pathname(entry);
QString extractToFolder = QFileInfo(path).absolutePath() + "/" + QFileInfo(path).baseName();
mkdir(extractToFolder.toUtf8().constData(), 600); // Create directory otherwise fopen will not open the file
mkdir(QFileInfo(path).baseName().toUtf8().constData(), 600); // Create directory otherwise fopen will not open the file
QString nameToWrite = extractToFolder + "/" + archive_entry_pathname(entry);
FILE* fileToWrite = fopen(nameToWrite.toUtf8().constData(), "wb");
fwrite((char*)archiveBuffer.get(), bytesToWrite, 1, fileToWrite);
fclose(fileToWrite);