diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-02 13:14:19 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-02 13:14:19 +0300 |
commit | 7ac2a23bc8083f0320d73af32f62ad97a407557b (patch) | |
tree | fc4004dacb288ebefce9420099cc29f67383d41a /launcher/FileSystem.cpp | |
parent | f8adb508ab0152af76829e0fdee92b451dcc1acf (diff) | |
parent | b51f1f1d41a6153c37b1d61a04df8ece5004cc27 (diff) | |
download | PrismLauncher-7ac2a23bc8083f0320d73af32f62ad97a407557b.tar.gz PrismLauncher-7ac2a23bc8083f0320d73af32f62ad97a407557b.tar.bz2 PrismLauncher-7ac2a23bc8083f0320d73af32f62ad97a407557b.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into catpacks
Diffstat (limited to 'launcher/FileSystem.cpp')
-rw-r--r-- | launcher/FileSystem.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 835ad925..3ce8dd2c 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -102,7 +102,7 @@ namespace fs = ghc::filesystem; #include <linux/fs.h> #include <sys/ioctl.h> #include <unistd.h> -#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD) +#elif defined(Q_OS_MACOS) #include <sys/attr.h> #include <sys/clonefile.h> #elif defined(Q_OS_WIN) @@ -372,7 +372,7 @@ void create_link::make_link_list(const QString& offset) auto src_path = source_it.next(); auto relative_path = src_dir.relativeFilePath(src_path); - if (m_max_depth >= 0 && pathDepth(relative_path) > m_max_depth){ + if (m_max_depth >= 0 && pathDepth(relative_path) > m_max_depth) { relative_path = pathTruncate(relative_path, m_max_depth); src_path = src_dir.filePath(relative_path); if (linkedPaths.contains(src_path)) { @@ -663,7 +663,7 @@ QString pathTruncate(const QString& path, int depth) QString trunc = QFileInfo(path).path(); - if (pathDepth(trunc) > depth ) { + if (pathDepth(trunc) > depth) { return pathTruncate(trunc, depth); } @@ -769,6 +769,9 @@ QString getDesktopDir() // Cross-platform Shortcut creation bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon) { + if (destination.isEmpty()) { + destination = PathCombine(getDesktopDir(), RemoveInvalidFilenameChars(name)); + } #if defined(Q_OS_MACOS) destination += ".command"; @@ -791,6 +794,8 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri return true; #elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) + if (!destination.endsWith(".desktop")) // in case of isFlatpak destination is already populated + destination += ".desktop"; QFile f(destination); f.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream stream(&f); @@ -974,7 +979,7 @@ FilesystemType getFilesystemType(const QString& name) { for (auto iter = s_filesystem_type_names.constBegin(); iter != s_filesystem_type_names.constEnd(); ++iter) { auto fs_names = iter.value(); - if(fs_names.contains(name.toUpper())) + if (fs_names.contains(name.toUpper())) return iter.key(); } return FilesystemType::UNKNOWN; @@ -1151,7 +1156,7 @@ bool clone_file(const QString& src, const QString& dst, std::error_code& ec) return false; } -#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD) +#elif defined(Q_OS_MACOS) if (!macos_bsd_clonefile(src_path, dst_path, ec)) { qDebug() << "failed macos_bsd_clonefile:"; @@ -1380,7 +1385,7 @@ bool linux_ficlone(const std::string& src_path, const std::string& dst_path, std return true; } -#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD) +#elif defined(Q_OS_MACOS) bool macos_bsd_clonefile(const std::string& src_path, const std::string& dst_path, std::error_code& ec) { |