LeechCraft  0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
paths.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <functional>
12 #include <QStringList>
13 #include <QFileInfo>
14 #include "sysconfig.h"
15 
16 class QDir;
17 class QUrl;
18 
19 namespace LC::Util
20 {
25  enum class SysPath
26  {
32  QML,
33 
39  Share
40  };
41 
68  UTIL_SYS_API QStringList GetPathCandidates (SysPath path, QString subfolder);
69 
98  UTIL_SYS_API QString GetSysPath (SysPath path, const QString& subfolder, const QString& filename);
99 
115  UTIL_SYS_API QUrl GetSysPathUrl (SysPath path, const QString& subfolder, const QString& filename);
116 
126  UTIL_SYS_API QStringList GetSystemPaths ();
127 
142  UTIL_SYS_API QString FindInSystemPath (const QString& name, const QStringList& paths,
143  const std::function<bool (QFileInfo)>& filter = {});
144 
147  enum class UserDir
148  {
151  Cache,
152 
155  LC
156  };
157 
158  UTIL_SYS_API QDir GetUserDir (UserDir dir, const QString& subpath);
159 
171  UTIL_SYS_API QDir CreateIfNotExists (QString path);
172 
181  UTIL_SYS_API QString GetTemporaryName (const QString& pattern = {});
182 
185  struct SpaceInfo
186  {
189  quint64 Capacity_;
190 
195  quint64 Free_;
196 
202  quint64 Available_;
203  };
204 
213  UTIL_SYS_API SpaceInfo GetSpaceInfo (const QString& path);
214 }
Root path for QML files.
SysPath
Describes various root paths recognized by GetSysPath().
Definition: paths.h:25
SpaceInfo GetSpaceInfo(const QString &path)
Returns the disk space info of the partition containing path.
Definition: paths.cpp:154
quint64 Free_
How much free space there is.
Definition: paths.h:195
Directory with shared data files.
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.
Definition: paths.cpp:79
QDir GetUserDir(UserDir dir, const QString &subpath)
Definition: paths.cpp:97
quint64 Capacity_
The capacity of the partition.
Definition: paths.h:189
QDir CreateIfNotExists(QString path)
Creates a path if it doesn&#39;t exist.
Definition: paths.cpp:126
#define UTIL_SYS_API
Definition: sysconfig.h:16
Cache for volatile data.
QUrl GetSysPathUrl(SysPath path, const QString &subfolder, const QString &filename)
Returns path to the file in the given root path and subfolder.
Definition: paths.cpp:69
QString GetSysPath(SysPath path, const QString &suffix, const QString &filename)
Returns path to the file in the given root path and subfolder.
Definition: paths.cpp:56
quint64 Available_
How much space is available to the current user.
Definition: paths.h:202
UserDir
Describes various user-specific paths.
Definition: paths.h:147
Contains information about a partition&#39;s disk space.
Definition: paths.h:185
QStringList GetSystemPaths()
Returns the components of the system PATH variable.
Definition: paths.cpp:74
QString GetTemporaryName(const QString &pattern)
Returns a temporary filename.
Definition: paths.cpp:143
QStringList GetPathCandidates(SysPath path, QString suffix)
Returns possible full paths for the path and subfolder.
Definition: paths.cpp:24