Fix Linux "invalid encoding" filename
This commit is contained in:
parent
7937406af6
commit
a5d9f69127
|
@ -1411,7 +1411,8 @@ std::string extractROM(char* zipName, std::string zipDir){
|
||||||
struct zip_stat st;
|
struct zip_stat st;
|
||||||
zip_stat_init(&st);
|
zip_stat_init(&st);
|
||||||
zip_stat_index(z, 0, 0, &st); //Get information about the file at index 0
|
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
|
//Allocate memory for its uncompressed contents
|
||||||
u8 *contents = new u8[st.size];
|
u8 *contents = new u8[st.size];
|
||||||
|
|
||||||
|
@ -1423,7 +1424,7 @@ std::string extractROM(char* zipName, std::string zipDir){
|
||||||
zip_close(z);
|
zip_close(z);
|
||||||
|
|
||||||
//Write the file (binary mode)
|
//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;
|
delete[] contents;
|
||||||
return zipDir + "/" + st.name;
|
return zipDir + "/" + st.name;
|
||||||
}
|
}
|
||||||
|
@ -1446,6 +1447,10 @@ void MainWindow::onOpenFile()
|
||||||
printf("Done.\n");
|
printf("Done.\n");
|
||||||
filename = QString::fromUtf8(extractRomLoc.c_str());
|
filename = QString::fromUtf8(extractRomLoc.c_str());
|
||||||
romExtracted = true;
|
romExtracted = true;
|
||||||
|
} else if (filenameExtLoc.completeSuffix().toUtf8() == "") {
|
||||||
|
//do nothing
|
||||||
|
} else {
|
||||||
|
romExtracted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
|
|
Loading…
Reference in New Issue