Fix loading of "themes" with non-ascii character names.

Fixed issue 6189.
Why did GetUserPath return a non-const ref to string..?
This commit is contained in:
Jordan Woyak
2013-04-01 23:17:15 -05:00
parent 4ba12be669
commit 69779a4321
5 changed files with 27 additions and 23 deletions

View File

@ -19,6 +19,7 @@
#include "CommonPaths.h"
#include "FileUtil.h"
#include "StringUtil.h"
#include "ConfigManager.h"
#ifdef _WIN32
#include <windows.h>
@ -669,7 +670,7 @@ std::string GetSysDirectory()
// Returns a string with a Dolphin data dir or file in the user's home
// directory. To be used in "multi-user" mode (that is, installed).
std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath)
{
static std::string paths[NUM_PATH_INDICES];
@ -742,6 +743,20 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
return paths[DirIDX];
}
std::string GetThemeDir()
{
std::string theme = SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name + "/";
std::string dir = File::GetUserPath(D_THEMES_IDX) + theme;
#if !defined(_WIN32)
// If theme does not exist in user's dir load from shared directory
if (!File::Exists(dir))
dir = SHARED_USER_DIR THEMES_DIR "/" + theme;
#endif
return dir;
}
bool WriteStringToFile(bool text_file, const std::string &str, const char *filename)
{
return File::IOFile(filename, text_file ? "w" : "wb").WriteBytes(str.data(), str.size());