mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Driver choice: Add error message for wrong file type
This commit is contained in:
parent
7634eba083
commit
969cb8ac18
3 changed files with 12 additions and 5 deletions
|
@ -1209,12 +1209,11 @@ bool WriteStringToFile(bool text_file, const std::string &str, const Path &filen
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WriteDataToFile(bool text_file, const void* data, const unsigned int size, const Path &filename) {
|
||||
bool WriteDataToFile(bool text_file, const void* data, size_t size, const Path &filename) {
|
||||
FILE *f = File::OpenCFile(filename, text_file ? "w" : "wb");
|
||||
if (!f)
|
||||
return false;
|
||||
size_t len = size;
|
||||
if (len != fwrite(data, 1, len, f))
|
||||
if (size != fwrite(data, 1, size, f))
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
|
|
|
@ -201,7 +201,7 @@ private:
|
|||
|
||||
// Whole-file reading/writing
|
||||
bool WriteStringToFile(bool text_file, const std::string &str, const Path &filename);
|
||||
bool WriteDataToFile(bool text_file, const void* data, const unsigned int size, const Path &filename);
|
||||
bool WriteDataToFile(bool text_file, const void* data, size_t size, const Path &filename);
|
||||
|
||||
bool ReadFileToString(bool text_file, const Path &filename, std::string &str);
|
||||
// Return value must be delete[]-d.
|
||||
|
|
|
@ -1269,6 +1269,8 @@ UI::EventReturn GameSettingsScreen::OnCustomDriverInstall(UI::EventParams &e) {
|
|||
if (!value.empty()) {
|
||||
Path zipPath = Path(value);
|
||||
|
||||
bool success = false;
|
||||
|
||||
if (zipPath.GetFileExtension() == ".zip") {
|
||||
ZipFileReader *zipFileReader = ZipFileReader::Create(zipPath, "");
|
||||
|
||||
|
@ -1304,9 +1306,15 @@ UI::EventReturn GameSettingsScreen::OnCustomDriverInstall(UI::EventParams &e) {
|
|||
|
||||
File::Delete(tempMeta);
|
||||
|
||||
success = true;
|
||||
|
||||
RecreateViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, gr->T("The selected file is not a ZIP file with a compatible driver."));
|
||||
}
|
||||
}
|
||||
});
|
||||
return UI::EVENT_DONE;
|
||||
|
|
Loading…
Add table
Reference in a new issue