aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl/EmuSettingsDialog.cpp
diff options
context:
space:
mode:
authorJaklyy <102590697+Jaklyy@users.noreply.github.com>2024-02-07 17:04:36 -0500
committerGitHub <noreply@github.com>2024-02-07 23:04:36 +0100
commit5ffa6429804a5668edf198a26a1595c170149798 (patch)
treec8265c1d9d975ef525848c8d5977998b763f191d /src/frontend/qt_sdl/EmuSettingsDialog.cpp
parent71e1ba8c40468385f2e66142cdbc943c4efb8f55 (diff)
Check for write permissions for some key files (#1972)
* check if an nds save file can be opened for writing also add the ability to open a file in append mode * fix multi-instance saves also move the check for file writability into a separate function (probably uneeded?) * implement check for gba roms * move rom load error messages into the functions also finish gba slot (oops) * improve error string * check write perms before saving path settings * fix memory leak * check for writability of firmware/nand/sds * add secondary checks for nand/firmware * add check for config file being writable * Return the file write error as a QString to avoid the invalid char* causing a garbled error message. Qt wants it as QString either way.
Diffstat (limited to 'src/frontend/qt_sdl/EmuSettingsDialog.cpp')
-rw-r--r--src/frontend/qt_sdl/EmuSettingsDialog.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.cpp b/src/frontend/qt_sdl/EmuSettingsDialog.cpp
index 0a834a6..ca9c671 100644
--- a/src/frontend/qt_sdl/EmuSettingsDialog.cpp
+++ b/src/frontend/qt_sdl/EmuSettingsDialog.cpp
@@ -380,6 +380,12 @@ void EmuSettingsDialog::on_btnFirmwareBrowse_clicked()
if (file.isEmpty()) return;
+ if (!Platform::CheckFileWritable(file.toStdString()))
+ {
+ QMessageBox::critical(this, "melonDS", "Unable to write to firmware file.\nPlease check file/folder write permissions.");
+ return;
+ }
+
updateLastBIOSFolder(file);
ui->txtFirmwarePath->setText(file);
@@ -436,6 +442,12 @@ void EmuSettingsDialog::on_btnDLDISDBrowse_clicked()
if (file.isEmpty()) return;
+ if (!Platform::CheckFileWritable(file.toStdString()))
+ {
+ QMessageBox::critical(this, "melonDS", "Unable to write to DLDI SD image.\nPlease check file/folder write permissions.");
+ return;
+ }
+
updateLastBIOSFolder(file);
ui->txtDLDISDPath->setText(file);
@@ -468,6 +480,13 @@ void EmuSettingsDialog::on_btnDSiFirmwareBrowse_clicked()
if (file.isEmpty()) return;
+ if (!Platform::CheckFileWritable(file.toStdString()))
+ {
+ QMessageBox::critical(this, "melonDS", "Unable to write to DSi firmware file.\nPlease check file/folder write permissions.");
+ return;
+ }
+
+
updateLastBIOSFolder(file);
ui->txtDSiFirmwarePath->setText(file);
@@ -482,6 +501,13 @@ void EmuSettingsDialog::on_btnDSiNANDBrowse_clicked()
if (file.isEmpty()) return;
+ if (!Platform::CheckFileWritable(file.toStdString()))
+ {
+ QMessageBox::critical(this, "melonDS", "Unable to write to DSi NAND image.\nPlease check file/folder write permissions.");
+ return;
+ }
+
+
updateLastBIOSFolder(file);
ui->txtDSiNANDPath->setText(file);
@@ -510,6 +536,12 @@ void EmuSettingsDialog::on_btnDSiSDBrowse_clicked()
if (file.isEmpty()) return;
+ if (!Platform::CheckFileWritable(file.toStdString()))
+ {
+ QMessageBox::critical(this, "melonDS", "Unable to write to DSi SD image.\nPlease check file/folder write permissions.");
+ return;
+ }
+
updateLastBIOSFolder(file);
ui->txtDSiSDPath->setText(file);