this uses qt's test location for AppData/Local, but leaves Roaming alone

This commit is contained in:
David Kelly 2017-06-23 11:06:48 -07:00
parent 04160f2ca1
commit bda50af780
3 changed files with 11 additions and 18 deletions

View file

@ -71,7 +71,7 @@ int main(int argc, const char* argv[]) {
QCommandLineOption runServerOption("runServer", "Whether to run the server");
QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath");
QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run");
QCommandLineOption overrideAppLocalDataPathOption("cache", "Override cache directory", "value");
QCommandLineOption overrideAppLocalDataPathOption("cache", "set test cache directory");
parser.addOption(urlOption);
parser.addOption(noUpdaterOption);
parser.addOption(checkMinSpecOption);
@ -99,8 +99,14 @@ int main(int argc, const char* argv[]) {
instanceMightBeRunning = false;
}
if (parser.isSet(overrideAppLocalDataPathOption)) {
QString appLocalDataPath = parser.value(overrideAppLocalDataPathOption);
PathUtils::getAppLocalDataPath(appLocalDataPath);
// get standard path
auto standardAppDataLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
// set to test so all future paths are the test paths
QStandardPaths::setTestModeEnabled(true);
// now, we need to link everything in AppDataLocation to the test AppDataLocation. This
// leaves the test location for AppLocalDataLocation alone, but allows all the stuff in
// AppDataLocation to be usable
QFile::link(standardAppDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}
if (instanceMightBeRunning) {

View file

@ -34,20 +34,7 @@ QString PathUtils::getAppDataPath() {
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/";
}
QString PathUtils::getAppLocalDataPath(const QString& overridePath) {
static QString overriddenPath = "";
// set the overridden path if one was passed in
if (!overridePath.isEmpty()) {
overriddenPath = overridePath;
}
// return overridden path if there is one
if (!overriddenPath.isEmpty()) {
return overriddenPath;
}
// otherwise return the standard path
QString PathUtils::getAppLocalDataPath() {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/";
}

View file

@ -28,7 +28,7 @@ public:
static const QString& resourcesPath();
static QString getAppDataPath();
static QString getAppLocalDataPath(const QString& overrideDataPath = "");
static QString getAppLocalDataPath();
static QString getAppDataFilePath(const QString& filename);
static QString getAppLocalDataFilePath(const QString& filename);