diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-08 11:35:50 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-15 06:03:13 -0800 |
commit | 4a146f9e57bf63c3555ebc048acc2012229fe08a (patch) | |
tree | 7c03284d1e737386bca93321ddff6b0222d1b445 /qthelper.cpp | |
parent | 3521cdcbd6bb2e282249286afe16b066e4af30e8 (diff) | |
download | subsurface-4a146f9e57bf63c3555ebc048acc2012229fe08a.tar.gz |
Add 'system_default_directory()' helper function
This is just a extern "C" wrapper around QStandardPaths::AppDataLocation,
while also making sure the entry exists.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qthelper.cpp')
-rw-r--r-- | qthelper.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index a4b644304..c591f90dd 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -12,6 +12,7 @@ #include <QDir> #include <QDebug> #include <QSettings> +#include <QStandardPaths> #include <QJsonDocument> #include <QJsonArray> #include <QJsonObject> @@ -298,6 +299,20 @@ picture_load_exit: return; } +extern "C" const char *system_default_directory(void) +{ + static char filename[PATH_MAX]; + + if (!*filename) { + QString name = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first(); + QDir dir(name); + dir.mkpath(name); + // Why no "dir.encodeName()"? Crazy Qt + strncpy(filename, QFile::encodeName(name), PATH_MAX-1); + } + return filename; +} + extern "C" char *get_file_name(const char *fileName) { QFileInfo fileInfo(fileName); |