20 #ifndef HEADER_FILE_MANAGER_HPP
21 #define HEADER_FILE_MANAGER_HPP
32 #include <irrString.h>
36 namespace io {
class IFileSystem; }
40 #include "io/xml_node.hpp"
41 #include "utils/no_copy.hpp"
45 std::string m_texture_search_path;
46 std::string m_container_id;
49 m_texture_search_path(path), m_container_id(container_id)
65 GFX, GRANDPRIX, GUI_ICON, GUI_SCREEN, GUI_DIALOG,
66 REPLAY, SHADER, SKIN, TTF, TRANSLATION, BUILTIN_ASSETS=TRANSLATION,
67 LIBRARY, MODEL, MUSIC, SFX, TEXTURE, SCRIPT, ASSET_MAX = SCRIPT,
110 std::vector<TextureSearchPath> m_texture_search_path;
112 std::vector<std::string>
115 bool findFile(std::string& full_path,
116 const std::string& fname,
117 const std::vector<std::string>& search_path)
119 bool findFile(std::string& full_path,
120 const std::string& fname,
121 const std::vector<TextureSearchPath>& search_path)
123 void makePath(std::string& path,
const std::string& dir,
124 const std::string& fname)
const;
125 io::path createAbsoluteFilename(
const std::string &f);
126 void checkAndCreateConfigDir();
127 void checkAndCreateAddonsDir();
128 void checkAndCreateScreenshotDir();
129 void checkAndCreateReplayDir();
130 void checkAndCreateCachedTexturesDir();
131 void checkAndCreateGPDir();
132 void discoverPaths();
133 void addAssetsSearchPath();
135 #if !defined(WIN32) && !defined(__APPLE__)
136 std::string checkAndCreateLinuxDir(
const char *env_name,
137 const char *dir_name,
138 const char *fallback1,
139 const char *fallback2=NULL);
146 void reinitAfterDownloadAssets();
147 static void addRootDirs(
const std::string &roots);
148 static void setStdoutName(
const std::string &name);
149 static void setStdoutDir(
const std::string &dir);
150 io::IXMLReader *createXMLReader(
const std::string &filename);
151 XMLNode *createXMLTree(
const std::string &filename);
152 XMLNode *createXMLTreeFromString(
const std::string & content);
154 std::string getScreenshotDir()
const;
155 std::string getReplayDir()
const;
156 std::string getCachedTexturesDir()
const;
157 std::string getGPDir()
const;
158 std::string getStdoutDir()
const;
159 bool checkAndCreateDirectory(
const std::string &path);
160 bool checkAndCreateDirectoryP(
const std::string &path);
161 const std::string &getAddonsDir()
const;
162 std::string getAddonsFile(
const std::string &name);
163 void checkAndCreateDirForAddons(
const std::string &dir);
164 static bool isDirectory(
const std::string &path);
165 bool removeFile(
const std::string &name)
const;
166 bool removeDirectory(
const std::string &name)
const;
168 bool moveDirectoryInto(std::string source, std::string target);
170 bool copyFile(
const std::string &source,
const std::string &dest);
171 std::vector<std::string>getMusicDirs()
const;
172 std::string getAssetChecked(
AssetType type,
const std::string& name,
173 bool abort_on_error=
false)
const;
174 std::string getAsset(
AssetType type,
const std::string &name)
const;
175 std::string getAsset(
const std::string &name)
const;
180 return m_subdir_name[type];
183 std::string searchMusic(
const std::string& file_name)
const;
185 std::string searchModel(
const std::string& file_name)
const;
186 std::string searchTexture(
const std::string& fname)
const;
187 std::string getUserConfigFile(
const std::string& fname)
const;
188 bool fileExists(
const std::string& path)
const;
192 bool fileExists(
const char *prefix,
const std::string& path)
const
194 return fileExists(std::string(prefix) + path);
197 bool searchTextureContainerId(std::string& container_id,
198 const std::string& file_name)
const;
203 void listFiles (std::set<std::string>& result,
204 const std::string& dir,
205 bool make_full_path=
false)
const;
208 void pushTextureSearchPath(
const std::string& path,
const std::string& container_id);
209 void pushModelSearchPath(
const std::string& path);
210 void popTextureSearchPath();
211 void popModelSearchPath();
212 void popMusicSearchPath();
213 void redirectOutput();
215 bool fileIsNewer(
const std::string& f1,
const std::string& f2)
const;
217 const std::string& getUserConfigDir()
const {
return m_user_config_dir; }
226 m_music_search_path.push_back(path);
235 return getAsset(SHADER, name);
239 std::string getShadersDir()
const
241 return m_subdir_name[SHADER];
244 const std::string& getSTKAssetsDownloadDir()
const
245 {
return m_stk_assets_download_dir; }
247 const std::string& getCertBundleLocation()
const
248 {
return m_cert_bundle_location; }
class handling files and paths
Definition: file_manager.hpp:59
std::string getAssetDirectory(AssetType type) const
Returns the directory of an asset.
Definition: file_manager.hpp:178
static const std::string & getStdoutName()
Returns the name of the stdout file for log messages.
Definition: file_manager.hpp:201
io::IFileSystem * m_file_system
Handle to irrlicht's file systems.
Definition: file_manager.hpp:75
std::vector< std::string > m_subdir_name
The names of the various subdirectories of the asset types.
Definition: file_manager.hpp:72
std::string m_addons_dir
Directory where addons are stored.
Definition: file_manager.hpp:81
static std::string m_stdout_filename
Name of stdout file.
Definition: file_manager.hpp:87
static std::string m_stdout_dir
Directory of stdout file.
Definition: file_manager.hpp:90
std::string m_user_config_dir
Directory where user config files are stored.
Definition: file_manager.hpp:78
std::string m_cached_textures_dir
Directory where resized textures are cached.
Definition: file_manager.hpp:99
std::string m_screenshot_dir
Directory to store screenshots in.
Definition: file_manager.hpp:93
std::string m_gp_dir
Directory where user-defined grand prix are stored.
Definition: file_manager.hpp:102
irr::io::IFileSystem * getFileSystem()
Returns the irrlicht file system.
Definition: file_manager.hpp:220
std::string m_replay_dir
Directory to store replays in.
Definition: file_manager.hpp:96
AssetType
The various asset types (and directories) STK might request.
Definition: file_manager.hpp:63
void pushMusicSearchPath(const std::string &path)
Adds a directory to the music search path (or stack).
Definition: file_manager.hpp:224
std::string m_cert_bundle_location
Location of the certificate bundle.
Definition: file_manager.hpp:105
std::string m_stk_assets_download_dir
Mobile stk specific to download stk-assets in the first.
Definition: file_manager.hpp:108
std::string getShader(const std::string &name) const
Returns the full path to a shader (this function could be modified later to allow track-specific shad...
Definition: file_manager.hpp:233
bool fileExists(const char *prefix, const std::string &path) const
Convenience function to save some typing in the file manager constructor.
Definition: file_manager.hpp:192
static std::vector< std::string > m_root_dirs
The list of all root directories.
Definition: file_manager.hpp:84
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
utility class used to parse XML files
Definition: xml_node.hpp:48
Definition: file_manager.hpp:44