diff options
Diffstat (limited to 'src/common/fs/path_util.cpp')
| -rw-r--r-- | src/common/fs/path_util.cpp | 70 |
1 files changed, 0 insertions, 70 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 | ||
| 351 | fs::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 | |||
| 390 | fs::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 | ||
| 423 | std::string_view RemoveTrailingSlash(std::string_view path) { | 353 | std::string_view RemoveTrailingSlash(std::string_view path) { |