main: Actively move all configs to new directory
Rather than move a config whenever the user opens the properties or starts a game, this just moves everything in one go. Co-Authored-By: Morph <morph1984@users.noreply.github.com>
This commit is contained in:
@@ -47,6 +47,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||
#include <QDesktopServices>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
@@ -274,6 +275,8 @@ GMainWindow::GMainWindow()
|
||||
if (args.length() >= 2) {
|
||||
BootGame(args[1]);
|
||||
}
|
||||
|
||||
MigrateConfigFiles();
|
||||
}
|
||||
|
||||
GMainWindow::~GMainWindow() {
|
||||
@@ -2167,6 +2170,28 @@ void GMainWindow::OnCaptureScreenshot() {
|
||||
OnStartGame();
|
||||
}
|
||||
|
||||
// TODO: Written 2020-07-23: Remove per-game config migration code when it is irrelevant
|
||||
void GMainWindow::MigrateConfigFiles() {
|
||||
const std::string& config_dir_s = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir);
|
||||
const QDir config_dir = QDir(QString::fromStdString(config_dir_s));
|
||||
const QStringList config_dir_list = config_dir.entryList(QStringList(QStringLiteral("*.ini")));
|
||||
|
||||
FileUtil::CreateFullPath(fmt::format("{}custom" DIR_SEP, config_dir_s));
|
||||
for (QStringList::const_iterator it = config_dir_list.constBegin();
|
||||
it != config_dir_list.constEnd(); it++) {
|
||||
const auto filename = it->toStdString();
|
||||
if (filename.find_first_not_of("0123456789abcdefACBDEF", 0) < 16) {
|
||||
continue;
|
||||
}
|
||||
const auto origin = fmt::format("{}{}", config_dir_s, filename);
|
||||
const auto destination = fmt::format("{}custom" DIR_SEP "{}", config_dir_s, filename);
|
||||
LOG_INFO(Frontend, "Migrating config file from {} to {}", origin, destination);
|
||||
if (FileUtil::Copy(origin, destination)) {
|
||||
FileUtil::Delete(origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GMainWindow::UpdateWindowTitle(const std::string& title_name,
|
||||
const std::string& title_version) {
|
||||
const auto full_name = std::string(Common::g_build_fullname);
|
||||
|
||||
@@ -232,6 +232,7 @@ private:
|
||||
std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
|
||||
InstallResult InstallNSPXCI(const QString& filename);
|
||||
InstallResult InstallNCA(const QString& filename);
|
||||
void MigrateConfigFiles();
|
||||
void UpdateWindowTitle(const std::string& title_name = {},
|
||||
const std::string& title_version = {});
|
||||
void UpdateStatusBar();
|
||||
|
||||
Reference in New Issue
Block a user