Fixed uglyness on OS X where directories called both SuperTuxKart and supertuxkart would be attempted to be created in App Support

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5615 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-07-01 18:11:22 +00:00
parent 58d8e91e20
commit e99d7592fb

View File

@ -380,7 +380,7 @@ bool FileManager::checkAndCreateDirectory(const std::string &path)
/** Checks if the config directory exists, and it not, tries to create it. */ /** Checks if the config directory exists, and it not, tries to create it. */
void FileManager::checkAndCreateConfigDir() void FileManager::checkAndCreateConfigDir()
{ {
#ifdef WIN32 #if defined(WIN32)
// Try to use the APPDATA directory to store config files and highscore // Try to use the APPDATA directory to store config files and highscore
// lists. If not defined, used the current directory. // lists. If not defined, used the current directory.
if(getenv("APPDATA")!=NULL) if(getenv("APPDATA")!=NULL)
@ -395,8 +395,11 @@ void FileManager::checkAndCreateConfigDir()
} }
else else
m_config_dir = "."; m_config_dir = ".";
#else const std::string CONFIGDIR("supertuxkart");
# ifdef __APPLE__
m_config_dir += "/";
m_config_dir += CONFIGDIR;
#elif defined(__APPLE__)
if (getenv("HOME")!=NULL) if (getenv("HOME")!=NULL)
{ {
m_config_dir = getenv("HOME"); m_config_dir = getenv("HOME");
@ -408,6 +411,8 @@ void FileManager::checkAndCreateConfigDir()
m_config_dir = ""; m_config_dir = "";
} }
m_config_dir += "/Library/Application Support/"; m_config_dir += "/Library/Application Support/";
const std::string CONFIGDIR("SuperTuxKart");
m_config_dir += CONFIGDIR;
# else # else
// Remaining unix variants. Use the new standards for config directory // Remaining unix variants. Use the new standards for config directory
// i.e. either XDG_CONFIG_HOME or $HOME/.config // i.e. either XDG_CONFIG_HOME or $HOME/.config
@ -432,12 +437,12 @@ void FileManager::checkAndCreateConfigDir()
m_config_dir += "."; m_config_dir += ".";
} }
} }
# endif
#endif
const std::string CONFIGDIR("supertuxkart"); const std::string CONFIGDIR("supertuxkart");
m_config_dir += "/"; m_config_dir += "/";
m_config_dir += CONFIGDIR; m_config_dir += CONFIGDIR;
#endif
if(!checkAndCreateDirectory(m_config_dir)) if(!checkAndCreateDirectory(m_config_dir))
{ {
fprintf(stderr, "Can not create config dir '%s', falling back to '.'.\n", fprintf(stderr, "Can not create config dir '%s', falling back to '.'.\n",