summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/fs/path_util.cpp70
-rw-r--r--src/common/fs/path_util.h15
-rw-r--r--src/yuzu/main.cpp16
-rw-r--r--src/yuzu/util/util.h3
4 files changed, 5 insertions, 99 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index f030939ce..bccf953e4 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -348,76 +348,6 @@ fs::path GetBundleDirectory() {
348 348
349#endif 349#endif
350 350
351fs::path GetDesktopPath() {
352#if defined(_WIN32)
353 PWSTR DesktopPath = nullptr;
354
355 if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &DesktopPath))) {
356 std::wstring wideDesktopPath(DesktopPath);
357 CoTaskMemFree(DesktopPath);
358
359 // UTF-16 filesystem lib to UTF-8 is broken, so we need to convert to UTF-8 with the with
360 // the Windows library (Filesystem converts the strings literally).
361 return fs::path{Common::UTF16ToUTF8(wideDesktopPath)};
362 } else {
363 LOG_ERROR(Common_Filesystem,
364 "[GetDesktopPath] Failed to get the path to the desktop directory");
365 }
366 return fs::path{};
367#else
368 fs::path shortcut_path{};
369
370 // Array of possible desktop
371 std::vector<std::string> desktop_paths = {
372 "Desktop", "Escritorio", "Bureau", "Skrivebord", "Plocha",
373 "Skrivbord", "Desktop", "Рабочий стол", "Pulpit", "Área de Trabalho",
374 "Робочий стіл", "Bureaublad", "デスクトップ", "桌面", "Pöytä",
375 "바탕 화면", "바탕 화면", "سطح المكتب", "دسکتاپ", "שולחן עבודה"};
376
377 for (auto& path : desktop_paths) {
378 if (fs::exists(GetHomeDirectory() / path)) {
379 return path;
380 }
381 }
382
383 LOG_ERROR(Common_Filesystem,
384 "[GetDesktopPath] Failed to get the path to the desktop directory");
385
386 return shortcut_path;
387#endif
388}
389
390fs::path GetAppsShortcutsPath() {
391#if defined(_WIN32)
392 PWSTR AppShortcutsPath = nullptr;
393
394 if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_CommonPrograms, 0, NULL, &AppShortcutsPath))) {
395 std::wstring wideAppShortcutsPath(AppShortcutsPath);
396 CoTaskMemFree(AppShortcutsPath);
397
398 // UTF-16 filesystem lib to UTF-8 is broken, so we need to convert to UTF-8 with the with
399 // the Windows library (Filesystem converts the strings literally).
400 return fs::path{Common::UTF16ToUTF8(wideAppShortcutsPath)};
401 } else {
402 LOG_ERROR(Common_Filesystem,
403 "[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts directory");
404 }
405
406 return fs::path{};
407#else
408 fs::path shortcut_path = GetHomeDirectory() / ".local/share/applications";
409 if (!fs::exists(shortcut_path)) {
410 shortcut_path = std::filesystem::path("/usr/share/applications");
411 if (!fs::exists(shortcut_path)) {
412 LOG_ERROR(Common_Filesystem,
413 "[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts "
414 "directory");
415 }
416 }
417 return fs::path{};
418#endif
419}
420
421// vvvvvvvvvv Deprecated vvvvvvvvvv // 351// vvvvvvvvvv Deprecated vvvvvvvvvv //
422 352
423std::string_view RemoveTrailingSlash(std::string_view path) { 353std::string_view RemoveTrailingSlash(std::string_view path) {
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h
index b88a388d1..63801c924 100644
--- a/src/common/fs/path_util.h
+++ b/src/common/fs/path_util.h
@@ -244,6 +244,7 @@ void SetYuzuPath(YuzuPath yuzu_path, const Path& new_path) {
244 * @returns The path of the current user's %APPDATA% directory. 244 * @returns The path of the current user's %APPDATA% directory.
245 */ 245 */
246[[nodiscard]] std::filesystem::path GetAppDataRoamingDirectory(); 246[[nodiscard]] std::filesystem::path GetAppDataRoamingDirectory();
247
247#else 248#else
248 249
249/** 250/**
@@ -274,20 +275,6 @@ void SetYuzuPath(YuzuPath yuzu_path, const Path& new_path) {
274 275
275#endif 276#endif
276 277
277/**
278 * Gets the path of the current user's desktop directory.
279 *
280 * @returns The path of the current user's desktop directory.
281 */
282[[nodiscard]] std::filesystem::path GetDesktopPath();
283
284/**
285 * Gets the path of the current user's apps directory.
286 *
287 * @returns The path of the current user's apps directory.
288 */
289[[nodiscard]] std::filesystem::path GetAppsShortcutsPath();
290
291// vvvvvvvvvv Deprecated vvvvvvvvvv // 278// vvvvvvvvvv Deprecated vvvvvvvvvv //
292 279
293// Removes the final '/' or '\' if one exists 280// Removes the final '/' or '\' if one exists
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index e4dc717ed..fd68ac9b6 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -3082,13 +3082,9 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
3082 // Shortcut path 3082 // Shortcut path
3083 std::filesystem::path shortcut_path{}; 3083 std::filesystem::path shortcut_path{};
3084 if (target == GameListShortcutTarget::Desktop) { 3084 if (target == GameListShortcutTarget::Desktop) {
3085 shortcut_path = Common::FS::GetDesktopPath(); 3085 shortcut_path =
3086 if (!std::filesystem::exists(shortcut_path)) { 3086 QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString();
3087 shortcut_path =
3088 QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString();
3089 }
3090 } else if (target == GameListShortcutTarget::Applications) { 3087 } else if (target == GameListShortcutTarget::Applications) {
3091
3092#if defined(_WIN32) 3088#if defined(_WIN32)
3093 HANDLE hProcess = GetCurrentProcess(); 3089 HANDLE hProcess = GetCurrentProcess();
3094 if (!IsUserAnAdmin()) { 3090 if (!IsUserAnAdmin()) {
@@ -3098,12 +3094,8 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
3098 } 3094 }
3099 CloseHandle(hProcess); 3095 CloseHandle(hProcess);
3100#endif // _WIN32 3096#endif // _WIN32
3101 3097 shortcut_path =
3102 shortcut_path = Common::FS::GetAppsShortcutsPath(); 3098 QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString();
3103 if (!std::filesystem::exists(shortcut_path)) {
3104 shortcut_path = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)
3105 .toStdString();
3106 }
3107 } 3099 }
3108 3100
3109 // Icon path and title 3101 // Icon path and title
diff --git a/src/yuzu/util/util.h b/src/yuzu/util/util.h
index 8839e160a..31e82ff67 100644
--- a/src/yuzu/util/util.h
+++ b/src/yuzu/util/util.h
@@ -8,11 +8,9 @@
8#include <QString> 8#include <QString>
9 9
10/// Returns a QFont object appropriate to use as a monospace font for debugging widgets, etc. 10/// Returns a QFont object appropriate to use as a monospace font for debugging widgets, etc.
11
12[[nodiscard]] QFont GetMonospaceFont(); 11[[nodiscard]] QFont GetMonospaceFont();
13 12
14/// Convert a size in bytes into a readable format (KiB, MiB, etc.) 13/// Convert a size in bytes into a readable format (KiB, MiB, etc.)
15
16[[nodiscard]] QString ReadableByteSize(qulonglong size); 14[[nodiscard]] QString ReadableByteSize(qulonglong size);
17 15
18/** 16/**
@@ -34,5 +32,4 @@
34 * 32 *
35 * @return bool If the operation succeeded 33 * @return bool If the operation succeeded
36 */ 34 */
37
38[[nodiscard]] bool SaveIconToFile(const QImage& image, const std::filesystem::path& icon_path); 35[[nodiscard]] bool SaveIconToFile(const QImage& image, const std::filesystem::path& icon_path);