Merge pull request #10703 from Dentomologist/remove_getsysdirectory_spam

Remove GetSysDirectory spam
This commit is contained in:
Admiral H. Curtiss 2022-06-02 19:20:48 +02:00 committed by GitHub
commit fc6ba6b686
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View file

@ -885,10 +885,8 @@ std::string GetExeDirectory()
#endif #endif
} }
std::string GetSysDirectory() static std::string CreateSysDirectoryPath()
{ {
std::string sysDir;
#if defined(_WIN32) || defined(LINUX_LOCAL_DEV) #if defined(_WIN32) || defined(LINUX_LOCAL_DEV)
#define SYSDATA_DIR "Sys" #define SYSDATA_DIR "Sys"
#elif defined __APPLE__ #elif defined __APPLE__
@ -902,25 +900,32 @@ std::string GetSysDirectory()
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
sysDir = GetBundleDirectory() + DIR_SEP + SYSDATA_DIR; const std::string sys_directory = GetBundleDirectory() + DIR_SEP SYSDATA_DIR DIR_SEP;
#elif defined(_WIN32) || defined(LINUX_LOCAL_DEV) #elif defined(_WIN32) || defined(LINUX_LOCAL_DEV)
sysDir = GetExeDirectory() + DIR_SEP + SYSDATA_DIR; const std::string sys_directory = GetExeDirectory() + DIR_SEP SYSDATA_DIR DIR_SEP;
#elif defined ANDROID #elif defined ANDROID
sysDir = s_android_sys_directory; const std::string sys_directory = s_android_sys_directory + DIR_SEP;
ASSERT_MSG(COMMON, !sysDir.empty(), "Sys directory has not been set"); ASSERT_MSG(COMMON, !s_android_sys_directory.empty(), "Sys directory has not been set");
#else #else
sysDir = SYSDATA_DIR; const std::string sys_directory = SYSDATA_DIR DIR_SEP;
#endif #endif
sysDir += DIR_SEP;
INFO_LOG_FMT(COMMON, "GetSysDirectory: Setting to {}:", sysDir); INFO_LOG_FMT(COMMON, "CreateSysDirectoryPath: Setting to {}", sys_directory);
return sysDir; return sys_directory;
}
const std::string& GetSysDirectory()
{
static const std::string sys_directory = CreateSysDirectoryPath();
return sys_directory;
} }
#ifdef ANDROID #ifdef ANDROID
void SetSysDirectory(const std::string& path) void SetSysDirectory(const std::string& path)
{ {
INFO_LOG_FMT(COMMON, "Setting Sys directory to {}", path); INFO_LOG_FMT(COMMON, "Setting Sys directory to {}", path);
ASSERT_MSG(COMMON, s_android_sys_directory.empty(), "Sys directory already set to {}",
s_android_sys_directory);
s_android_sys_directory = path; s_android_sys_directory = path;
} }
#endif #endif

View file

@ -215,7 +215,7 @@ void SetUserPath(unsigned int dir_index, std::string path);
std::string GetThemeDir(const std::string& theme_name); std::string GetThemeDir(const std::string& theme_name);
// Returns the path to where the sys file are // Returns the path to where the sys file are
std::string GetSysDirectory(); const std::string& GetSysDirectory();
#ifdef ANDROID #ifdef ANDROID
void SetSysDirectory(const std::string& path); void SetSysDirectory(const std::string& path);