Portable mode: accept 'portable.txt'

This commit is contained in:
tobtoht 2022-05-22 19:52:03 +02:00
parent 52705375be
commit 4fcf746c3a
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
3 changed files with 15 additions and 6 deletions

View file

@ -102,10 +102,18 @@ bool dirExists(const QString &path) {
return pathDir.exists();
}
bool portableFileExists(const QString &dir) {
QStringList portableFiles = {".portable", ".portable.txt", "portable.txt"};
return std::find_if(portableFiles.begin(), portableFiles.end(), [dir](const QString &portableFile){
return QFile::exists(dir + "/" + portableFile);
}) != portableFiles.end();
}
QString defaultWalletDir() {
QString portablePath = QCoreApplication::applicationDirPath().append("/%1");
if (QFile::exists(portablePath.arg(".portable")) || QFile::exists(portablePath.arg(".portable.txt"))) {
return portablePath.arg("feather_data/wallets");
QString portablePath = QCoreApplication::applicationDirPath();
if (Utils::portableFileExists(portablePath)) {
return portablePath + "/feather_data/wallets";
}
if (TailsOS::detect()) {

View file

@ -22,6 +22,7 @@ namespace Utils
QStringList fileFind(const QRegularExpression &pattern, const QString &baseDir, int level, int depth, int maxPerDir);
bool dirExists(const QString &path);
bool portableFileExists(const QString &dir);
QString defaultWalletDir();
QString applicationPath();

View file

@ -168,9 +168,9 @@ Config::Config(QObject* parent)
}
QDir Config::defaultConfigDir() {
QString portablePath = QCoreApplication::applicationDirPath().append("/%1");
if (QFile::exists(portablePath.arg(".portable")) || QFile::exists(portablePath.arg(".portable.txt"))) {
return portablePath.arg("feather_data");
QString portablePath = QCoreApplication::applicationDirPath();
if (Utils::portableFileExists(portablePath)) {
return portablePath + "/feather_data";
}
if (TailsOS::detect()) {