mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
create leading directories of settings filepath
for compatibility with code expecting it to be created Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
db53ab28e4
commit
2622c69097
1 changed files with 10 additions and 8 deletions
|
@ -220,11 +220,18 @@ static QSettingsCustomFormat getSettingsFormat(QSettings::Format format)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline QString createLeadingDir(const QString &filename)
|
||||||
|
{
|
||||||
|
QFileInfo info(filename);
|
||||||
|
QDir().mkpath(info.absolutePath());
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
static QString getSettingsPath(QSettings::Scope scope, const QString &filename, const QString &extension)
|
static QString getSettingsPath(QSettings::Scope scope, const QString &filename, const QString &extension)
|
||||||
{
|
{
|
||||||
QFileInfo info(filename);
|
QFileInfo info(filename);
|
||||||
if (info.isAbsolute()) {
|
if (info.isAbsolute()) {
|
||||||
return filename;
|
return createLeadingDir(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString nameandext = filename;
|
QString nameandext = filename;
|
||||||
|
@ -240,17 +247,12 @@ static QString getSettingsPath(QSettings::Scope scope, const QString &filename,
|
||||||
foreach (const QString &location, locations) {
|
foreach (const QString &location, locations) {
|
||||||
QDir dir(location);
|
QDir dir(location);
|
||||||
if (dir.exists(location)) {
|
if (dir.exists(location)) {
|
||||||
return location + QDir::separator() + nameandext;
|
return createLeadingDir(location + QDir::separator() + nameandext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString fallback = QLibraryInfo::location(QLibraryInfo::SettingsPath);
|
const QString fallback = QLibraryInfo::location(QLibraryInfo::SettingsPath);
|
||||||
QDir fallbackdir(fallback);
|
return createLeadingDir(fallback + QDir::separator() + nameandext);
|
||||||
if (!fallbackdir.mkpath(fallback)) {
|
|
||||||
qWarning("QSettingsPrivate::getSettingsPath: no settings location");
|
|
||||||
fallbackdir.currentPath() + QDir::separator() + nameandext;
|
|
||||||
}
|
|
||||||
return fallback + QDir::separator() + nameandext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettingsPrivate::QSettingsPrivate(QSettings::Format format, QSettings::Scope scope)
|
QSettingsPrivate::QSettingsPrivate(QSettings::Format format, QSettings::Scope scope)
|
||||||
|
|
Loading…
Add table
Reference in a new issue