diff options
author | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-02-12 02:44:39 -0700 |
---|---|---|
committer | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-03-20 14:56:32 -0700 |
commit | a1053a4c5ac8651be3b57814918e28179eb2a1f9 (patch) | |
tree | 598e2c8a5acb4bf03510d36225bff82934bf3b45 /launcher/minecraft/mod/Resource.cpp | |
parent | 9f441a9678f56c5fb5efbc415b3faff176609b9c (diff) | |
download | PrismLauncher-a1053a4c5ac8651be3b57814918e28179eb2a1f9.tar.gz PrismLauncher-a1053a4c5ac8651be3b57814918e28179eb2a1f9.tar.bz2 PrismLauncher-a1053a4c5ac8651be3b57814918e28179eb2a1f9.zip |
feat: warnings when instance resources are linked
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/minecraft/mod/Resource.cpp')
-rw-r--r-- | launcher/minecraft/mod/Resource.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/launcher/minecraft/mod/Resource.cpp b/launcher/minecraft/mod/Resource.cpp index 0d35d755..a0b8a4bb 100644 --- a/launcher/minecraft/mod/Resource.cpp +++ b/launcher/minecraft/mod/Resource.cpp @@ -1,6 +1,8 @@ #include "Resource.h" + #include <QRegularExpression> +#include <QFileInfo> #include "FileSystem.h" @@ -152,3 +154,21 @@ bool Resource::destroy() return FS::deletePath(m_file_info.filePath()); } + +bool Resource::isSymLinkUnder(const QString& instPath) const +{ + if (isSymLink()) + return true; + + auto instDir = QDir(instPath); + + auto relAbsPath = instDir.relativeFilePath(m_file_info.absoluteFilePath()); + auto relCanonPath = instDir.relativeFilePath(m_file_info.canonicalFilePath()); + + return relAbsPath != relCanonPath; +} + +bool Resource::isMoreThanOneHardLink() const +{ + return FS::hardLinkCount(m_file_info.absoluteFilePath()) > 1; +} |