From 3dea1a9f8189129d12fc852e8c012796d71ecec3 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:11:41 -0700 Subject: [PATCH] qt: Create addons directory if it does not exist. (#1186) --- src/common/path_util.h | 1 - src/qt_gui/game_install_dialog.cpp | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/path_util.h b/src/common/path_util.h index af0e91832..9bde2e287 100644 --- a/src/common/path_util.h +++ b/src/common/path_util.h @@ -44,7 +44,6 @@ constexpr auto DOWNLOAD_DIR = "download"; constexpr auto CAPTURES_DIR = "captures"; constexpr auto CHEATS_DIR = "cheats"; constexpr auto PATCHES_DIR = "patches"; -constexpr auto ADDONS_DIR = "addcont"; constexpr auto METADATA_DIR = "game_data"; // Filenames diff --git a/src/qt_gui/game_install_dialog.cpp b/src/qt_gui/game_install_dialog.cpp index 8f7ffd5d1..11daf2de0 100644 --- a/src/qt_gui/game_install_dialog.cpp +++ b/src/qt_gui/game_install_dialog.cpp @@ -111,12 +111,19 @@ void GameInstallDialog::Save() { return; } - if (addonsDirectory.isEmpty() || !QDir(addonsDirectory).exists() || - !QDir::isAbsolutePath(addonsDirectory)) { + if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) { QMessageBox::critical(this, tr("Error"), "The value for location to install DLC is not valid."); return; } + QDir addonsDir(addonsDirectory); + if (!addonsDir.exists()) { + if (!addonsDir.mkpath(".")) { + QMessageBox::critical(this, tr("Error"), + "The DLC install location could not be created."); + return; + } + } Config::setGameInstallDir(Common::FS::PathFromQString(gamesDirectory)); Config::setAddonInstallDir(Common::FS::PathFromQString(addonsDirectory));