|
|
|
@ -348,76 +348,6 @@ fs::path GetBundleDirectory() {
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
fs::path GetDesktopPath() {
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
|
PWSTR DesktopPath = nullptr;
|
|
|
|
|
|
|
|
|
|
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &DesktopPath))) {
|
|
|
|
|
std::wstring wideDesktopPath(DesktopPath);
|
|
|
|
|
CoTaskMemFree(DesktopPath);
|
|
|
|
|
|
|
|
|
|
// UTF-16 filesystem lib to UTF-8 is broken, so we need to convert to UTF-8 with the with
|
|
|
|
|
// the Windows library (Filesystem converts the strings literally).
|
|
|
|
|
return fs::path{Common::UTF16ToUTF8(wideDesktopPath)};
|
|
|
|
|
} else {
|
|
|
|
|
LOG_ERROR(Common_Filesystem,
|
|
|
|
|
"[GetDesktopPath] Failed to get the path to the desktop directory");
|
|
|
|
|
}
|
|
|
|
|
return fs::path{};
|
|
|
|
|
#else
|
|
|
|
|
fs::path shortcut_path{};
|
|
|
|
|
|
|
|
|
|
// Array of possible desktop
|
|
|
|
|
std::vector<std::string> desktop_paths = {
|
|
|
|
|
"Desktop", "Escritorio", "Bureau", "Skrivebord", "Plocha",
|
|
|
|
|
"Skrivbord", "Desktop", "Рабочий стол", "Pulpit", "Área de Trabalho",
|
|
|
|
|
"Робочий стіл", "Bureaublad", "デスクトップ", "桌面", "Pöytä",
|
|
|
|
|
"바탕 화면", "바탕 화면", "سطح المكتب", "دسکتاپ", "שולחן עבודה"};
|
|
|
|
|
|
|
|
|
|
for (auto& path : desktop_paths) {
|
|
|
|
|
if (fs::exists(GetHomeDirectory() / path)) {
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_ERROR(Common_Filesystem,
|
|
|
|
|
"[GetDesktopPath] Failed to get the path to the desktop directory");
|
|
|
|
|
|
|
|
|
|
return shortcut_path;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs::path GetAppsShortcutsPath() {
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
|
PWSTR AppShortcutsPath = nullptr;
|
|
|
|
|
|
|
|
|
|
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_CommonPrograms, 0, NULL, &AppShortcutsPath))) {
|
|
|
|
|
std::wstring wideAppShortcutsPath(AppShortcutsPath);
|
|
|
|
|
CoTaskMemFree(AppShortcutsPath);
|
|
|
|
|
|
|
|
|
|
// UTF-16 filesystem lib to UTF-8 is broken, so we need to convert to UTF-8 with the with
|
|
|
|
|
// the Windows library (Filesystem converts the strings literally).
|
|
|
|
|
return fs::path{Common::UTF16ToUTF8(wideAppShortcutsPath)};
|
|
|
|
|
} else {
|
|
|
|
|
LOG_ERROR(Common_Filesystem,
|
|
|
|
|
"[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts directory");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fs::path{};
|
|
|
|
|
#else
|
|
|
|
|
fs::path shortcut_path = GetHomeDirectory() / ".local/share/applications";
|
|
|
|
|
if (!fs::exists(shortcut_path)) {
|
|
|
|
|
shortcut_path = std::filesystem::path("/usr/share/applications");
|
|
|
|
|
if (!fs::exists(shortcut_path)) {
|
|
|
|
|
LOG_ERROR(Common_Filesystem,
|
|
|
|
|
"[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts "
|
|
|
|
|
"directory");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fs::path{};
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// vvvvvvvvvv Deprecated vvvvvvvvvv //
|
|
|
|
|
|
|
|
|
|
std::string_view RemoveTrailingSlash(std::string_view path) {
|
|
|
|
|