aboutsummaryrefslogtreecommitdiff
path: root/launcher/FileSystem.h
diff options
context:
space:
mode:
authorRyan Cao <70191398+ryanccn@users.noreply.github.com>2022-07-31 01:42:33 +0800
committerGitHub <noreply@github.com>2022-07-30 14:42:33 -0300
commitb15544c163ccbca08ea498b3b3a51c82d7fb3e12 (patch)
treea2a129505f5932f082c0a348a583c859af1030a2 /launcher/FileSystem.h
parent94a63e3859e576658d832c62cffacbb6963ad1e6 (diff)
downloadPrismLauncher-b15544c163ccbca08ea498b3b3a51c82d7fb3e12.tar.gz
PrismLauncher-b15544c163ccbca08ea498b3b3a51c82d7fb3e12.tar.bz2
PrismLauncher-b15544c163ccbca08ea498b3b3a51c82d7fb3e12.zip
Trash instances instead of deleting (when possible) (#549)
Squashed because of :pofat: commit history
Diffstat (limited to 'launcher/FileSystem.h')
-rw-r--r--launcher/FileSystem.h51
1 files changed, 25 insertions, 26 deletions
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index fd305b01..b46f3281 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -41,29 +41,27 @@
#include <QDir>
#include <QFlags>
-namespace FS
-{
+namespace FS {
-class FileSystemException : public ::Exception
-{
-public:
- FileSystemException(const QString &message) : Exception(message) {}
+class FileSystemException : public ::Exception {
+ public:
+ FileSystemException(const QString& message) : Exception(message) {}
};
/**
* write data to a file safely
*/
-void write(const QString &filename, const QByteArray &data);
+void write(const QString& filename, const QByteArray& data);
/**
* read data from a file safely\
*/
-QByteArray read(const QString &filename);
+QByteArray read(const QString& filename);
/**
* Update the last changed timestamp of an existing file
*/
-bool updateTimestamp(const QString & filename);
+bool updateTimestamp(const QString& filename);
/**
* Creates all the folders in a path for the specified path
@@ -77,35 +75,31 @@ bool ensureFilePathExists(QString filenamepath);
*/
bool ensureFolderPathExists(QString filenamepath);
-class copy
-{
-public:
- copy(const QString & src, const QString & dst)
+class copy {
+ public:
+ copy(const QString& src, const QString& dst)
{
m_src.setPath(src);
m_dst.setPath(dst);
}
- copy & followSymlinks(const bool follow)
+ copy& followSymlinks(const bool follow)
{
m_followSymlinks = follow;
return *this;
}
- copy & blacklist(const IPathMatcher * filter)
+ copy& blacklist(const IPathMatcher* filter)
{
m_blacklist = filter;
return *this;
}
- bool operator()()
- {
- return operator()(QString());
- }
+ bool operator()() { return operator()(QString()); }
-private:
- bool operator()(const QString &offset);
+ private:
+ bool operator()(const QString& offset);
-private:
+ private:
bool m_followSymlinks = true;
- const IPathMatcher * m_blacklist = nullptr;
+ const IPathMatcher* m_blacklist = nullptr;
QDir m_src;
QDir m_dst;
};
@@ -115,9 +109,14 @@ private:
*/
bool deletePath(QString path);
-QString PathCombine(const QString &path1, const QString &path2);
-QString PathCombine(const QString &path1, const QString &path2, const QString &path3);
-QString PathCombine(const QString &path1, const QString &path2, const QString &path3, const QString &path4);
+/**
+ * Trash a folder / file
+ */
+bool trash(QString path, QString *pathInTrash);
+
+QString PathCombine(const QString& path1, const QString& path2);
+QString PathCombine(const QString& path1, const QString& path2, const QString& path3);
+QString PathCombine(const QString& path1, const QString& path2, const QString& path3, const QString& path4);
QString AbsolutePath(QString path);