From 1b877c9a16eb9ed041007accf13d713f488699a2 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Fri, 9 Oct 2009 00:37:29 +0000 Subject: [PATCH] Removed usage of deprecated irrlicht IO interface, cleaned up usage of different file archives (since irrlicht now supports removing paths from a file archive). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4100 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/io/file_manager.cpp | 49 ++++++++++++++++++++++++++++++++--------- src/io/file_manager.hpp | 5 +++-- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp index 94844c4cb..b8678a87c 100644 --- a/src/io/file_manager.cpp +++ b/src/io/file_manager.cpp @@ -132,10 +132,10 @@ FileManager::FileManager() TrackManager::addTrackSearchDir(m_root_dir+"/data/tracks"); KartPropertiesManager::addKartSearchDir(m_root_dir+"/data/karts"); - pushTextureSearchPath(m_root_dir+"/data/textures"); - pushModelSearchPath (m_root_dir+"/data/models" ); - pushMusicSearchPath (m_root_dir+"/data/music" ); - m_file_system->addFolderFileArchive("data/models", + pushTextureSearchPath(m_root_dir+"/data/textures/"); + pushModelSearchPath (m_root_dir+"/data/models/" ); + pushMusicSearchPath (m_root_dir+"/data/music/" ); + m_file_system->addFileArchive("data/models/", /*ignoreCase*/false, /*ignorePaths*/false); // Add more paths from the STK_MUSIC_PATH environment variable @@ -196,24 +196,53 @@ XMLNode *FileManager::createXMLTree(const std::string &filename) return new XMLNode(xml_reader); } // getXMLTree +//----------------------------------------------------------------------------- +/** In order to add and later remove paths we have to specify the absolute + * filename (and replace '\' with '/' on windows). + */ +io::path FileManager::createAbsoluteFilename(const std::string &f) +{ + io::path abs_path=m_file_system->getAbsolutePath(f.c_str()); + abs_path=m_file_system->flattenFilename(abs_path); + return abs_path; +} // createAbsoluteFilename + //----------------------------------------------------------------------------- void FileManager::pushModelSearchPath(const std::string& path) { m_model_search_path.push_back(path); - m_file_system->addFolderFileArchive(path.c_str(), - /*ignoreCase*/false, - /*ignorePaths*/false); + m_file_system->addFileArchive(createAbsoluteFilename(path), + /*ignoreCase*/false, + /*ignorePaths*/false, + io::EFAT_FOLDER); } // pushModelSearchPath //----------------------------------------------------------------------------- void FileManager::pushTextureSearchPath(const std::string& path) { m_texture_search_path.push_back(path); - m_file_system->addFolderFileArchive(path.c_str(), - /*ignoreCase*/false, - /*ignorePaths*/false); + m_file_system->addFileArchive(createAbsoluteFilename(path), + /*ignoreCase*/false, + /*ignorePaths*/false, + io::EFAT_FOLDER); } // pushTextureSearchPath +//----------------------------------------------------------------------------- +void FileManager::popTextureSearchPath() +{ + std::string dir = m_texture_search_path.back(); + m_texture_search_path.pop_back(); + m_file_system->removeFileArchive(createAbsoluteFilename(dir)); +} // popTextureSearchPath + +//----------------------------------------------------------------------------- +void FileManager::popModelSearchPath() +{ + std::string dir = m_model_search_path.back(); + m_model_search_path.pop_back(); + m_file_system->removeFileArchive(createAbsoluteFilename(dir)); +} // popModelSearchPath + //----------------------------------------------------------------------------- bool FileManager::findFile(std::string& full_path, const std::string& fname, diff --git a/src/io/file_manager.hpp b/src/io/file_manager.hpp index 22996d4b6..541276c40 100644 --- a/src/io/file_manager.hpp +++ b/src/io/file_manager.hpp @@ -50,6 +50,7 @@ private: const; void makePath (std::string& path, const std::string& dir, const std::string& fname) const; + io::path createAbsoluteFilename(const std::string &f); public: FileManager(); @@ -89,8 +90,8 @@ public: void pushModelSearchPath (const std::string& path); void pushMusicSearchPath (const std::string& path) { m_music_search_path.push_back(path); } - void popTextureSearchPath () {m_texture_search_path.pop_back(); } - void popModelSearchPath () {m_model_search_path.pop_back(); } + void popTextureSearchPath (); + void popModelSearchPath (); void popMusicSearchPath () {m_music_search_path.pop_back(); } };