From d673445d812ab7df5b318006be38ba9d1b879dca Mon Sep 17 00:00:00 2001 From: Madhav Kanbur Date: Fri, 8 Jan 2021 16:20:57 +0530 Subject: [PATCH] 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 --- src/frontend/qt_sdl/ArchiveUtil.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frontend/qt_sdl/ArchiveUtil.cpp b/src/frontend/qt_sdl/ArchiveUtil.cpp index ba6e4b64..6c2423e0 100644 --- a/src/frontend/qt_sdl/ArchiveUtil.cpp +++ b/src/frontend/qt_sdl/ArchiveUtil.cpp @@ -91,9 +91,10 @@ QVector ExtractFileFromArchive(const char* path, const char* wantedFile archiveBuffer.reset(nullptr); return QVector {"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);