Skip to content
Snippets Groups Projects
Commit c88a95f8 authored by akiraohgaki's avatar akiraohgaki
Browse files

Update library

parent cdf4deba
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "file.h" #include "file.h"
#include <QIODevice> #include <QIODevice>
#include <QStandardPaths>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
...@@ -19,14 +20,6 @@ ...@@ -19,14 +20,6 @@
namespace utils { namespace utils {
/**
* XDG Base Directory Specification
* http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
*
* KDE System Administration/Environment Variables
* https://userbase.kde.org/KDE_System_Administration/Environment_Variables
*/
File::File(QObject *parent) : QObject(parent) File::File(QObject *parent) : QObject(parent)
{} {}
...@@ -45,35 +38,26 @@ QString File::homePath() ...@@ -45,35 +38,26 @@ QString File::homePath()
return QDir::homePath(); return QDir::homePath();
} }
QString File::xdgDataHomePath() QString File::genericDataPath()
{ {
QString path = QString::fromLocal8Bit(qgetenv("XDG_DATA_HOME").constData()); return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
if (path.isEmpty()) {
path = homePath() + "/.local/share";
}
return path;
} }
QString File::xdgConfigHomePath() QString File::genericConfigPath()
{ {
QString path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData()); return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
if (path.isEmpty()) {
path = homePath() + "/.config";
}
return path;
} }
QString File::xdgCacheHomePath() QString File::genericCachePath()
{ {
QString path = QString::fromLocal8Bit(qgetenv("XDG_CACHE_HOME").constData()); return QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
if (path.isEmpty()) {
path = homePath() + "/.cache";
}
return path;
} }
QString File::kdehomePath() QString File::kdehomePath()
{ {
// KDE System Administration/Environment Variables
// https://userbase.kde.org/KDE_System_Administration/Environment_Variables
// KDE 4 maybe uses $KDEHOME // KDE 4 maybe uses $KDEHOME
QString path = QString::fromLocal8Bit(qgetenv("KDEHOME").constData()); QString path = QString::fromLocal8Bit(qgetenv("KDEHOME").constData());
if (path.isEmpty()) { if (path.isEmpty()) {
......
...@@ -28,9 +28,9 @@ public: ...@@ -28,9 +28,9 @@ public:
static QString rootPath(); static QString rootPath();
static QString tempPath(); static QString tempPath();
static QString homePath(); static QString homePath();
static QString xdgDataHomePath(); static QString genericDataPath();
static QString xdgConfigHomePath(); static QString genericConfigPath();
static QString xdgCacheHomePath(); static QString genericCachePath();
static QString kdehomePath(); static QString kdehomePath();
static QFileInfoList readDir(const QString &path); static QFileInfoList readDir(const QString &path);
static bool makeDir(const QString &path); static bool makeDir(const QString &path);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment