diff options
author | WaluigiWare64 <68647953+WaluigiWare64@users.noreply.github.com> | 2020-07-24 18:19:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-24 18:19:02 +0100 |
commit | a5d9f6912742b33eab3e9dcee40be72a69cf94bb (patch) | |
tree | f488b0dee04a44a9a1656fa835a0aaa2d9764291 /src/frontend/qt_sdl | |
parent | 7937406af6c9825bed23f9947f9c0e05d3c4b71e (diff) |
Fix Linux "invalid encoding" filename
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index f77c287..c0268bc 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -1411,7 +1411,8 @@ std::string extractROM(char* zipName, std::string zipDir){ struct zip_stat st; zip_stat_init(&st); zip_stat_index(z, 0, 0, &st); //Get information about the file at index 0 - + char newName[255]; + strcpy(newName, st.name); //fix for Linux invalid encoding filename //Allocate memory for its uncompressed contents u8 *contents = new u8[st.size]; @@ -1423,7 +1424,7 @@ std::string extractROM(char* zipName, std::string zipDir){ zip_close(z); //Write the file (binary mode) - std::ofstream(zipDir + "/" + st.name, std::ofstream::binary).write((char*) contents, st.size); + std::ofstream(zipDir + "/" + newName, std::ofstream::binary).write((char*) contents, st.size); delete[] contents; return zipDir + "/" + st.name; } @@ -1441,11 +1442,15 @@ void MainWindow::onOpenFile() if (filenameExtLoc.completeSuffix().toUtf8() == "zip") { - printf("Extracting ROM from ZIP...\n"); - std::string extractRomLoc = extractROM(filename.toUtf8().data(), filenameExtLoc.absolutePath().toUtf8().data()); - printf("Done.\n"); - filename = QString::fromUtf8(extractRomLoc.c_str()); - romExtracted = true; + printf("Extracting ROM from ZIP...\n"); + std::string extractRomLoc = extractROM(filename.toUtf8().data(), filenameExtLoc.absolutePath().toUtf8().data()); + printf("Done.\n"); + filename = QString::fromUtf8(extractRomLoc.c_str()); + romExtracted = true; + } else if (filenameExtLoc.completeSuffix().toUtf8() == "") { + //do nothing + } else { + romExtracted = false; } if (filename.isEmpty()) |