aboutsummaryrefslogtreecommitdiff
path: root/launcher/FileSystem.h
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-02-06 23:05:06 -0800
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-03-20 14:56:27 -0700
commitf794e49bb6eadd70c52683e60a700a1d7e9cd17b (patch)
tree1f5de4708a17937fa1721b73bf8c1c56542f2f72 /launcher/FileSystem.h
parent6dcf34acdc8ec3dcbb094e4981ef136cd6a99913 (diff)
downloadPrismLauncher-f794e49bb6eadd70c52683e60a700a1d7e9cd17b.tar.gz
PrismLauncher-f794e49bb6eadd70c52683e60a700a1d7e9cd17b.tar.bz2
PrismLauncher-f794e49bb6eadd70c52683e60a700a1d7e9cd17b.zip
we want to make links!
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/FileSystem.h')
-rw-r--r--launcher/FileSystem.h68
1 files changed, 67 insertions, 1 deletions
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index f083f3c7..98f55f96 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -77,7 +77,9 @@ bool ensureFilePathExists(QString filenamepath);
*/
bool ensureFolderPathExists(QString filenamepath);
-/// @brief Copies a directory and it's contents from src to dest
+/**
+ * @brief Copies a directory and it's contents from src to dest
+ */
class copy : public QObject {
Q_OBJECT
public:
@@ -123,6 +125,70 @@ class copy : public QObject {
};
/**
+ * @brief Copies a directory and it's contents from src to dest
+ */
+class create_link : public QObject {
+ Q_OBJECT
+ public:
+ create_link(const QString& src, const QString& dst, QObject* parent = nullptr) : QObject(parent)
+ {
+ m_src.setPath(src);
+ m_dst.setPath(dst);
+ }
+ create_link& useHardLinks(const bool useHard)
+ {
+ m_useHardLinks = useHard;
+ return *this;
+ }
+ create_link& matcher(const IPathMatcher* filter)
+ {
+ m_matcher = filter;
+ return *this;
+ }
+ create_link& whitelist(bool whitelist)
+ {
+ m_whitelist = whitelist;
+ return *this;
+ }
+ create_link& linkRecursively(bool recursive)
+ {
+ m_recursive = recursive;
+ return *this;
+ }
+ create_link& debug(bool d)
+ {
+ m_debug = d;
+ return *this;
+ }
+
+ int getLastOSError() {
+ return m_last_os_err;
+ }
+
+ bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); }
+
+ int totalLinked() { return m_linked; }
+
+ signals:
+ void fileLinked(const QString& relativeName);
+ void linkFailed(const QString& srcName, const QString& dstName, std::error_code err);
+
+ private:
+ bool operator()(const QString& offset, bool dryRun = false);
+
+ private:
+ bool m_useHardLinks = false;
+ const IPathMatcher* m_matcher = nullptr;
+ bool m_whitelist = false;
+ bool m_recursive = true;
+ QDir m_src;
+ QDir m_dst;
+ int m_linked;
+ bool m_debug = false;
+ int m_last_os_err = 0;
+};
+
+/**
* @brief moves a file by renaming it
* @param source source file path
* @param dest destination filepath