Added permissions check

This commit is contained in:
Matthew 2024-09-17 03:21:27 +02:00
parent 8e85eff13e
commit 421be5b01f
1 changed files with 14 additions and 0 deletions

View File

@ -11,6 +11,8 @@
#include "common/Path.h"
#include "common/StringUtil.h"
#include <unistd.h>
MemoryCardConvertDialog::MemoryCardConvertDialog(QWidget* parent, QString selectedCard)
: QDialog(parent)
{
@ -253,6 +255,18 @@ void MemoryCardConvertDialog::ConvertCard()
size_t num = 0;
QString destName = baseName;
destName.append(".ps2");
QString fullPath = Path::Combine(EmuFolders::MemoryCards, destName.toStdString()).c_str();
QDir destinationDir(fullPath);
QString absolutePath = destinationDir.absolutePath(); // Get the absolute path
if (access(absolutePath.toStdString().c_str(), R_OK | W_OK | X_OK) != 0)
{
QMessageBox::critical(this, tr("Cannot Convert Memory Card"),
tr("You have insufficient permissions to convert this Memory Card. Please ensure that you have read/write access to the folder \n \"%1\".")
.arg(absolutePath));
return;
}
// If a match is found, revert back to the base name, add a number and the extension, and try again.
// Keep incrementing the number until we get a unique result.