13#include <QTemporaryFile>
14#if defined (Q_OS_WIN32) || defined (Q_OS_MAC)
15#include <QApplication>
20#include <QStandardPaths>
35 return { QApplication::applicationDirPath () +
"/share/" +
suffix };
36#elif defined (Q_OS_MAC) && !defined (USE_UNIX_LAYOUT)
37 return { QApplication::applicationDirPath () +
"/../Resources/share/" +
suffix };
44 "/usr/local/share/leechcraft/" +
suffix,
45 "/usr/share/leechcraft/" +
suffix
51 <<
"unknown system path"
52 <<
static_cast<int> (
path);
91 return fi.absoluteFilePath ();
103 path = QStandardPaths::writableLocation (QStandardPaths::CacheLocation);
106 path = QDir::home ().path () +
"/.leechcraft/";
111 throw std::runtime_error (
"cannot get root path");
113 if (!
path.endsWith (
'/'))
121 throw std::runtime_error (
"cannot create path " +
path.toStdString ());
128 auto home = QDir::home ();
129 path.prepend (
".leechcraft/");
133 throw std::runtime_error (
qPrintable (QObject::tr (
"Could not create %1")
134 .
arg (QDir::toNativeSeparators (
home.filePath (
path)))));
137 throw std::runtime_error (
qPrintable (QObject::tr (
"Could not cd into %1")
138 .
arg (QDir::toNativeSeparators (
home.filePath (
path)))));
156 const auto&
info = std::filesystem::space (
path.toStdString ());
159 .Capacity_ =
info.capacity,
161 .Available_ =
info.available
Container< T > Filter(const Container< T > &c, F f)
QString GetSysPath(SysPath path, const QString &suffix, const QString &filename)
Returns path to the file in the given root path and subfolder.
QStringList GetSystemPaths()
Returns the components of the system PATH variable.
QString GetTemporaryName(const QString &pattern)
Returns a temporary filename.
QString FindInSystemPath(const QString &name, const QStringList &paths, const std::function< bool(QFileInfo)> &filter)
Searches for a file in system paths according to a filter.
UserDir
Describes various user-specific paths.
@ LC
Root LeechCraft directory (something like ~/.leechcraft).
@ Cache
Cache for volatile data.
QStringList GetPathCandidates(SysPath path, QString suffix)
Returns possible full paths for the path and subfolder.
QDir GetUserDir(UserDir dir, const QString &subpath)
QUrl GetSysPathUrl(SysPath path, const QString &subfolder, const QString &filename)
Returns path to the file in the given root path and subfolder.
SysPath
Describes various root paths recognized by GetSysPath().
@ Share
Directory with shared data files.
@ QML
Root path for QML files.
SpaceInfo GetSpaceInfo(const QString &path)
Returns the disk space info of the partition containing path.
QDir CreateIfNotExists(QString path)
Creates a path if it doesn't exist.
Contains information about a partition's disk space.