Better detection of writeability of current app directory.
This commit is contained in:
parent
8486b072a6
commit
9b886427ef
@ -24,12 +24,25 @@
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
IOFactory::IOFactory() {
|
||||
}
|
||||
|
||||
bool IOFactory::isFolderWritable(const QString &folder) {
|
||||
QString real_file = folder;
|
||||
|
||||
if (!real_file.endsWith(QDir::separator())) {
|
||||
real_file += QDir::separator();
|
||||
}
|
||||
|
||||
real_file += "test-permissions-file";
|
||||
|
||||
return QTemporaryFile(real_file).open();
|
||||
}
|
||||
|
||||
QString IOFactory::getSystemFolder(QStandardPaths::StandardLocation location) {
|
||||
return QStandardPaths::writableLocation(location);
|
||||
}
|
||||
|
@ -31,7 +31,9 @@ class IOFactory {
|
||||
private:
|
||||
IOFactory();
|
||||
|
||||
public:
|
||||
public:
|
||||
static bool isFolderWritable(const QString &folder);
|
||||
|
||||
// Returns system-wide folder according to type.
|
||||
static QString getSystemFolder(QStandardPaths::StandardLocation location);
|
||||
|
||||
|
@ -332,7 +332,7 @@ SettingsProperties Settings::determineProperties() {
|
||||
const QString home_path = qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME);
|
||||
const QString home_path_file = home_path + properties.m_settingsSuffix;
|
||||
|
||||
const bool portable_settings_available = QFileInfo(app_path).isWritable();
|
||||
const bool portable_settings_available = IOFactory::isFolderWritable(app_path);
|
||||
const bool non_portable_settings_exist = QFile::exists(home_path_file);
|
||||
|
||||
// We will use PORTABLE settings only and only if it is available and NON-PORTABLE
|
||||
|
Loading…
x
Reference in New Issue
Block a user