qBittorrent
fs.h
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * In addition, as a special exception, the copyright holders give permission to
20  * link this program with the OpenSSL project's "OpenSSL" library (or with
21  * modified versions of it that use the same license as the "OpenSSL" library),
22  * and distribute the linked executables. You must obey the GNU General Public
23  * License in all respects for all of the code used other than "OpenSSL". If you
24  * modify file(s), you may extend this exception to your version of the file(s),
25  * but you are not obligated to do so. If you do not wish to do so, delete this
26  * exception statement from your version.
27  */
28 
29 #pragma once
30 
35 #include <QString>
36 
37 namespace Utils::Fs
38 {
44  QString toNativePath(const QString &path);
45 
52  QString toUniformPath(const QString &path);
53 
57  QString resolvePath(const QString &relativePath, const QString &basePath);
58 
62  QString fileExtension(const QString &filename);
63 
64  QString fileName(const QString &filePath);
65  QString folderName(const QString &filePath);
66  qint64 computePathSize(const QString &path);
67  bool sameFiles(const QString &path1, const QString &path2);
68  QString toValidFileSystemName(const QString &name, bool allowSeparators = false
69  , const QString &pad = QLatin1String(" "));
70  bool isValidFileSystemName(const QString &name, bool allowSeparators = false);
71  qint64 freeDiskSpaceOnPath(const QString &path);
72  QString branchPath(const QString &filePath, QString *removed = nullptr);
73  bool sameFileNames(const QString &first, const QString &second);
74  QString expandPath(const QString &path);
75  QString expandPathAbs(const QString &path);
76  bool isRegularFile(const QString &path);
77 
78  bool smartRemoveEmptyFolderTree(const QString &path);
79  bool forceRemove(const QString &filePath);
80  void removeDirRecursive(const QString &path);
81 
82  QString tempPath();
83 
84  QString findRootFolder(const QStringList &filePaths);
85  void stripRootFolder(QStringList &filePaths);
86  void addRootFolder(QStringList &filePaths, const QString &name);
87 
88 #if !defined Q_OS_HAIKU
89  bool isNetworkFileSystem(const QString &path);
90 #endif
91 }
Definition: fs.h:38
bool isRegularFile(const QString &path)
Definition: fs.cpp:321
bool sameFiles(const QString &path1, const QString &path2)
Definition: fs.cpp:220
bool isNetworkFileSystem(const QString &path)
Definition: fs.cpp:337
qint64 freeDiskSpaceOnPath(const QString &path)
Definition: fs.cpp:271
QString folderName(const QString &filePath)
Definition: fs.cpp:96
bool sameFileNames(const QString &first, const QString &second)
Definition: fs.cpp:291
QString fileName(const QString &filePath)
Definition: fs.cpp:87
QString toValidFileSystemName(const QString &name, bool allowSeparators=false, const QString &pad=QLatin1String(" "))
Definition: fs.cpp:237
void stripRootFolder(QStringList &filePaths)
Definition: fs.cpp:422
QString resolvePath(const QString &relativePath, const QString &basePath)
Definition: fs.cpp:74
void removeDirRecursive(const QString &path)
Definition: fs.cpp:187
qint64 computePathSize(const QString &path)
Definition: fs.cpp:199
QString fileExtension(const QString &filename)
Definition: fs.cpp:82
QString findRootFolder(const QStringList &filePaths)
Definition: fs.cpp:403
void addRootFolder(QStringList &filePaths, const QString &name)
Definition: fs.cpp:432
bool isValidFileSystemName(const QString &name, bool allowSeparators=false)
Definition: fs.cpp:248
QString tempPath()
Definition: fs.cpp:314
QString toUniformPath(const QString &path)
Definition: fs.cpp:69
QString branchPath(const QString &filePath, QString *removed=nullptr)
Definition: fs.cpp:276
QString expandPathAbs(const QString &path)
Definition: fs.cpp:309
bool smartRemoveEmptyFolderTree(const QString &path)
Definition: fs.cpp:114
bool forceRemove(const QString &filePath)
Definition: fs.cpp:173
QString expandPath(const QString &path)
Definition: fs.cpp:300
QString toNativePath(const QString &path)
Definition: fs.cpp:64