diff options
| author | Silarn <jrim@rimpo.org> | 2019-07-08 13:19:52 -0500 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2019-07-08 13:19:52 -0500 |
| commit | 37aa5e07f473e0377ef59d6e2f53f7373b11aecd (patch) | |
| tree | 6ceefc40dd166c5d88f3f4cccdfb6274d8e445ad /src | |
| parent | e4bacba282d273754d1791000d24db52275ac7e2 (diff) | |
Add some basic checks for symlinks
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 18 | ||||
| -rw-r--r-- | src/organizercore.cpp | 17 | ||||
| -rw-r--r-- | src/organizercore.h | 1 | ||||
| -rw-r--r-- | src/selectiondialog.cpp | 8 | ||||
| -rw-r--r-- | src/selectiondialog.h | 1 |
5 files changed, 43 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index 4a2f6035..f2571685 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -303,6 +303,11 @@ MOBase::IPluginGame *determineCurrentGame(QString const &moPath, QSettings &sett gamePath = game->gameDirectory().absolutePath(); } QDir gameDir(gamePath); + QFileInfo directoryInfo(gameDir.path()); + if (directoryInfo.isSymLink()) { + reportError(QObject::tr("The configured path to the game directory (%1) appears to be a symbolic (or other) link. " + "This setup is incompatible with MO2's VFS and will not run correctly.").arg(gamePath)); + } if (game->looksValid(gameDir)) { return selectGame(settings, gameDir, game); } @@ -335,15 +340,26 @@ MOBase::IPluginGame *determineCurrentGame(QString const &moPath, QSettings &sett while (selection.exec() != QDialog::Rejected) { IPluginGame * game = selection.getChoiceData().value<IPluginGame *>(); + QString gamePath = selection.getChoiceDescription(); + QFileInfo directoryInfo(gamePath); + if (directoryInfo.isSymLink()) { + reportError(QObject::tr("The configured path to the game directory (%1) appears to be a symbolic (or other) link. " + "This setup is incompatible with MO2's VFS and will not run correctly.").arg(gamePath)); + } if (game != nullptr) { return selectGame(settings, game->gameDirectory(), game); } - QString gamePath = QFileDialog::getExistingDirectory(nullptr, gameConfigured ? QObject::tr("Please select the installation of %1 to manage").arg(gameName) + gamePath = QFileDialog::getExistingDirectory(nullptr, gameConfigured ? QObject::tr("Please select the installation of %1 to manage").arg(gameName) : QObject::tr("Please select the game to manage"), QString(), QFileDialog::ShowDirsOnly); if (!gamePath.isEmpty()) { QDir gameDir(gamePath); + QFileInfo directoryInfo(gamePath); + if (directoryInfo.isSymLink()) { + reportError(QObject::tr("The configured path to the game directory (%1) appears to be a symbolic (or other) link. " + "This setup is incompatible with MO2's VFS and will not run correctly.").arg(gamePath)); + } QList<IPluginGame *> possibleGames; for (IPluginGame * const game : plugins.plugins<IPluginGame>()) { //If a game is already configured, skip any plugins that are not for that game diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 99ddda1d..81ec7f43 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -691,12 +691,27 @@ bool OrganizerCore::createDirectory(const QString &path) { } } +bool OrganizerCore::checkPathSymlinks() { + bool hasSymlink = (QFileInfo(m_Settings.getProfileDirectory()).isSymLink() || + QFileInfo(m_Settings.getModDirectory()).isSymLink() || + QFileInfo(m_Settings.getOverwriteDirectory()).isSymLink()); + if (hasSymlink) { + QMessageBox::critical(nullptr, QObject::tr("Error"), + QObject::tr("One of the configured MO2 directories (profiles, mods, or overwrite) " + "is on a path containing a symbolic (or other) link. This is incompatible " + "with MO2's VFS system.")); + return false; + } + return true; +} + bool OrganizerCore::bootstrap() { return createDirectory(m_Settings.getProfileDirectory()) && createDirectory(m_Settings.getModDirectory()) && createDirectory(m_Settings.getDownloadDirectory()) && createDirectory(m_Settings.getOverwriteDirectory()) && - createDirectory(QString::fromStdWString(crashDumpsPath())) && cycleDiagnostics(); + createDirectory(QString::fromStdWString(crashDumpsPath())) && + checkPathSymlinks() && cycleDiagnostics(); } void OrganizerCore::createDefaultProfile() diff --git a/src/organizercore.h b/src/organizercore.h index 4dd11831..99b1c5f2 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -183,6 +183,7 @@ public: void loginFailedUpdate(const QString &message);
static bool createAndMakeWritable(const QString &path);
+ bool checkPathSymlinks();
bool bootstrap();
void createDefaultProfile();
diff --git a/src/selectiondialog.cpp b/src/selectiondialog.cpp index 55728751..089760f9 100644 --- a/src/selectiondialog.cpp +++ b/src/selectiondialog.cpp @@ -79,6 +79,14 @@ QString SelectionDialog::getChoiceString() }
}
+QString SelectionDialog::getChoiceDescription()
+{
+ if (m_Choice == nullptr)
+ return QString();
+ else
+ return m_Choice->accessibleDescription();
+}
+
void SelectionDialog::disableCancel()
{
ui->cancelButton->setEnabled(false);
diff --git a/src/selectiondialog.h b/src/selectiondialog.h index 3c4b25df..5a70aa5e 100644 --- a/src/selectiondialog.h +++ b/src/selectiondialog.h @@ -52,6 +52,7 @@ public: QVariant getChoiceData();
QString getChoiceString();
+ QString getChoiceDescription();
void disableCancel();
|
