Create the directory where resized textures will be cached.

This commit is contained in:
Guillaume P 2014-04-29 18:57:36 +02:00
parent 03fbdc260d
commit fac9cafa96
2 changed files with 39 additions and 0 deletions

View File

@ -192,6 +192,7 @@ FileManager::FileManager()
checkAndCreateConfigDir();
checkAndCreateAddonsDir();
checkAndCreateScreenshotDir();
checkAndCreateCachedTexturesDir();
checkAndCreateGPDir();
#ifdef WIN32
@ -596,6 +597,14 @@ std::string FileManager::getScreenshotDir() const
return m_screenshot_dir;
} // getScreenshotDir
//-----------------------------------------------------------------------------
/** Returns the directory in which resized textures should be cached.
*/
std::string FileManager::getCachedTexturesDir() const
{
return m_cached_textures_dir;
} // getCachedTexturesDir
//-----------------------------------------------------------------------------
/** Returns the directory in which user-defined grand prix should be stored.
*/
@ -852,6 +861,31 @@ void FileManager::checkAndCreateScreenshotDir()
} // checkAndCreateScreenshotDir
// ----------------------------------------------------------------------------
/** Creates the directories for cached textures. This will set
* m_cached_textures_dir with the appropriate path.
*/
void FileManager::checkAndCreateCachedTexturesDir()
{
#if defined(WIN32) || defined(__CYGWIN__)
m_cached_textures_dir = m_user_config_dir + "resized-textures/";
#elif defined(__APPLE__)
m_cached_textures_dir = getenv("HOME");
m_cached_textures_dir += "/Library/Application Support/SuperTuxKart/ResizedTextures/";
#else
m_cached_textures_dir = checkAndCreateLinuxDir("XDG_CACHE_HOME", "supertuxkart", ".cache/", ".");
m_cached_textures_dir += "resized-textures/";
#endif
if (!checkAndCreateDirectory(m_cached_textures_dir))
{
Log::error("FileManager", "Can not create cached textures directory '%s', "
"falling back to '.'.", m_cached_textures_dir.c_str());
m_cached_textures_dir = ".";
}
} // checkAndCreateCachedTexturesDir
// ----------------------------------------------------------------------------
/** Creates the directories for user-defined grand prix. This will set m_gp_dir
* with the appropriate path.

View File

@ -72,6 +72,9 @@ private:
/** Directory to store screenshots in. */
std::string m_screenshot_dir;
/** Directory where resized textures are cached. */
std::string m_cached_textures_dir;
/** Directory where user-defined grand prix are stored. */
std::string m_gp_dir;
@ -91,6 +94,7 @@ private:
bool isDirectory(const std::string &path) const;
void checkAndCreateAddonsDir();
void checkAndCreateScreenshotDir();
void checkAndCreateCachedTexturesDir();
void checkAndCreateGPDir();
#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(__APPLE__)
std::string checkAndCreateLinuxDir(const char *env_name,
@ -110,6 +114,7 @@ public:
XMLNode *createXMLTreeFromString(const std::string & content);
std::string getScreenshotDir() const;
std::string getCachedTexturesDir() const;
std::string getGPDir() const;
bool checkAndCreateDirectoryP(const std::string &path);
const std::string &getAddonsDir() const;