From 4a146f9e57bf63c3555ebc048acc2012229fe08a Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 8 Feb 2015 11:35:50 -0800 Subject: 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 Signed-off-by: Dirk Hohndel --- qthelper.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'qthelper.cpp') diff --git a/qthelper.cpp b/qthelper.cpp index a4b644304..c591f90dd 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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); -- cgit v1.2.3-70-g09d2