Seperate directory for replay files
It allows replay GUI to load them easier
This commit is contained in:
parent
a6c4a72e2c
commit
5cd27f8f99
@ -213,6 +213,7 @@ FileManager::FileManager()
|
||||
checkAndCreateConfigDir();
|
||||
checkAndCreateAddonsDir();
|
||||
checkAndCreateScreenshotDir();
|
||||
checkAndCreateReplayDir();
|
||||
checkAndCreateCachedTexturesDir();
|
||||
checkAndCreateGPDir();
|
||||
|
||||
@ -641,6 +642,14 @@ std::string FileManager::getScreenshotDir() const
|
||||
return m_screenshot_dir;
|
||||
} // getScreenshotDir
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the directory in which replay file should be stored.
|
||||
*/
|
||||
std::string FileManager::getReplayDir() const
|
||||
{
|
||||
return m_replay_dir;
|
||||
} // getReplayDir
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the directory in which resized textures should be cached.
|
||||
*/
|
||||
@ -910,6 +919,32 @@ void FileManager::checkAndCreateScreenshotDir()
|
||||
|
||||
} // checkAndCreateScreenshotDir
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Creates the directories for replay recorded. This will set m_replay_dir
|
||||
* with the appropriate path.
|
||||
*/
|
||||
void FileManager::checkAndCreateReplayDir()
|
||||
{
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
m_replay_dir = m_user_config_dir + "replay/";
|
||||
#elif defined(__APPLE__)
|
||||
m_replay_dir = getenv("HOME");
|
||||
m_replay_dir += "/Library/Application Support/SuperTuxKart/replay/";
|
||||
#else
|
||||
m_replay_dir = checkAndCreateLinuxDir("XDG_DATA_HOME", "supertuxkart",
|
||||
".local/share", ".supertuxkart");
|
||||
m_replay_dir += "replay/";
|
||||
#endif
|
||||
|
||||
if(!checkAndCreateDirectory(m_replay_dir))
|
||||
{
|
||||
Log::error("FileManager", "Can not create replay directory '%s', "
|
||||
"falling back to '.'.", m_replay_dir.c_str());
|
||||
m_replay_dir = ".";
|
||||
}
|
||||
|
||||
} // checkAndCreateReplayDir
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Creates the directories for cached textures. This will set
|
||||
* m_cached_textures_dir with the appropriate path.
|
||||
|
@ -75,6 +75,9 @@ private:
|
||||
/** Directory to store screenshots in. */
|
||||
std::string m_screenshot_dir;
|
||||
|
||||
/** Directory to store replays in. */
|
||||
std::string m_replay_dir;
|
||||
|
||||
/** Directory where resized textures are cached. */
|
||||
std::string m_cached_textures_dir;
|
||||
|
||||
@ -97,6 +100,7 @@ private:
|
||||
bool isDirectory(const std::string &path) const;
|
||||
void checkAndCreateAddonsDir();
|
||||
void checkAndCreateScreenshotDir();
|
||||
void checkAndCreateReplayDir();
|
||||
void checkAndCreateCachedTexturesDir();
|
||||
void checkAndCreateGPDir();
|
||||
void discoverPaths();
|
||||
@ -118,6 +122,7 @@ public:
|
||||
XMLNode *createXMLTreeFromString(const std::string & content);
|
||||
|
||||
std::string getScreenshotDir() const;
|
||||
std::string getReplayDir() const;
|
||||
std::string getCachedTexturesDir() const;
|
||||
std::string getGPDir() const;
|
||||
std::string getTextureCacheLocation(const std::string& filename);
|
||||
|
@ -33,13 +33,12 @@ ReplayBase::ReplayBase()
|
||||
*/
|
||||
FILE* ReplayBase::openReplayFile(bool writeable)
|
||||
{
|
||||
m_filename = file_manager->getUserConfigFile(
|
||||
race_manager->getTrackName()+".replay");
|
||||
m_filename = file_manager->getReplayDir() +
|
||||
race_manager->getTrackName() + ".replay";
|
||||
FILE *fd = fopen(m_filename.c_str(), writeable ? "w" : "r");
|
||||
if(!fd)
|
||||
if (!fd)
|
||||
{
|
||||
m_filename = race_manager->getTrackName()+".replay";
|
||||
fd = fopen(m_filename.c_str(), writeable ? "w" : "r");
|
||||
return NULL;
|
||||
}
|
||||
return fd;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user