Merge pull request #68504 from dzil123/cache_system_dir_xdg2

Cache OS_LinuxBSD::get_system_dir
This commit is contained in:
Rémi Verschelde 2022-11-15 00:18:09 +01:00 committed by GitHub
commit 98e0d59952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -128,6 +128,8 @@ void OS_LinuxBSD::initialize() {
crash_handler.initialize(); crash_handler.initialize();
OS_Unix::initialize_core(); OS_Unix::initialize_core();
system_dir_desktop_cache = get_system_dir(SYSTEM_DIR_DESKTOP);
} }
void OS_LinuxBSD::initialize_joypads() { void OS_LinuxBSD::initialize_joypads() {
@ -719,6 +721,10 @@ String OS_LinuxBSD::get_cache_path() const {
} }
String OS_LinuxBSD::get_system_dir(SystemDir p_dir, bool p_shared_storage) const { String OS_LinuxBSD::get_system_dir(SystemDir p_dir, bool p_shared_storage) const {
if (p_dir == SYSTEM_DIR_DESKTOP && !system_dir_desktop_cache.is_empty()) {
return system_dir_desktop_cache;
}
String xdgparam; String xdgparam;
switch (p_dir) { switch (p_dir) {
@ -727,31 +733,24 @@ String OS_LinuxBSD::get_system_dir(SystemDir p_dir, bool p_shared_storage) const
} break; } break;
case SYSTEM_DIR_DCIM: { case SYSTEM_DIR_DCIM: {
xdgparam = "PICTURES"; xdgparam = "PICTURES";
} break; } break;
case SYSTEM_DIR_DOCUMENTS: { case SYSTEM_DIR_DOCUMENTS: {
xdgparam = "DOCUMENTS"; xdgparam = "DOCUMENTS";
} break; } break;
case SYSTEM_DIR_DOWNLOADS: { case SYSTEM_DIR_DOWNLOADS: {
xdgparam = "DOWNLOAD"; xdgparam = "DOWNLOAD";
} break; } break;
case SYSTEM_DIR_MOVIES: { case SYSTEM_DIR_MOVIES: {
xdgparam = "VIDEOS"; xdgparam = "VIDEOS";
} break; } break;
case SYSTEM_DIR_MUSIC: { case SYSTEM_DIR_MUSIC: {
xdgparam = "MUSIC"; xdgparam = "MUSIC";
} break; } break;
case SYSTEM_DIR_PICTURES: { case SYSTEM_DIR_PICTURES: {
xdgparam = "PICTURES"; xdgparam = "PICTURES";
} break; } break;
case SYSTEM_DIR_RINGTONES: { case SYSTEM_DIR_RINGTONES: {
xdgparam = "MUSIC"; xdgparam = "MUSIC";
} break; } break;
} }

View File

@ -72,6 +72,8 @@ class OS_LinuxBSD : public OS_Unix {
Vector<String> lspci_device_filter(Vector<String> vendor_device_id_mapping, String class_suffix, String check_column, String whitelist) const; Vector<String> lspci_device_filter(Vector<String> vendor_device_id_mapping, String class_suffix, String check_column, String whitelist) const;
Vector<String> lspci_get_device_value(Vector<String> vendor_device_id_mapping, String check_column, String blacklist) const; Vector<String> lspci_get_device_value(Vector<String> vendor_device_id_mapping, String check_column, String blacklist) const;
String system_dir_desktop_cache;
protected: protected:
virtual void initialize() override; virtual void initialize() override;
virtual void finalize() override; virtual void finalize() override;