mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
3521cdcbd6
commit
4a146f9e57
2 changed files with 17 additions and 0 deletions
2
pref.h
2
pref.h
|
@ -94,6 +94,8 @@ extern struct preferences prefs, default_prefs;
|
|||
|
||||
extern const char *system_divelist_default_font;
|
||||
extern double system_divelist_default_font_size;
|
||||
|
||||
extern const char *system_default_directory(void);
|
||||
extern const char *system_default_filename();
|
||||
extern bool subsurface_ignore_font(const char *font);
|
||||
extern void subsurface_OS_pref_setup();
|
||||
|
|
15
qthelper.cpp
15
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue