TrueReality  v0.1.1912
PathUtils.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * The Base of this class has been adopted from the Delta3D engine
6 *
7 * This library is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 3.0 of the License, or (at your option)
10 * any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Class Inspired by the Delta3D Engine
22 * http://delta3dengine.org/
23 *
24 * @author David Guthrie
25 * @author John K. Grant
26 * @author William E. Johnson II
27 * @author Chris Osborn
28 * @author Maxim Serebrennik
29 */
30 #pragma once
31 
32 #include <trUtil/Export.h>
33 
34 #include <trUtil/PlatformMacros.h>
35 #include <trUtil/RefStr.h>
36 
37 #include <string>
38 #include <vector>
39 
40 
42 {
43 #ifdef TR_APPLE
44  const static std::string DEFAULT_TR_FOLDER("/TrueReality");
45 #elif defined(TR_WIN)
46  const static std::string DEFAULT_TR_FOLDER("\\TrueReality");
47 #else
48  const static std::string DEFAULT_TR_FOLDER("/.trueReality");
49 #endif
50  const static std::string DATA_PATH_DEFAULT("/Data");
51  const static std::string STATIC_MESHES_PATH("/StaticMeshes");
52  const static std::string SKELETAL_MESHES_PATH("/SkeletalMeshes");
53  const static std::string SOUNDS_PATH("/Sounds");
54  const static std::string PARTICLES_PATH("/Particles");
55  const static std::string TEXTURES_PATH("/Textures");
56  const static std::string TERRAINS_PATH("/Terrains");
57  const static std::string SHADERS_PATH("/Shaders");
58  const static std::string GUI_PATH("/GUI");
59  const static std::string CONFIG_PATH("/Config");
60 
69 
80  TR_UTIL_EXPORT std::string GetUserDataPath();
81 
89  TR_UTIL_EXPORT std::string GetStaticMeshesPath();
90 
99 
107  TR_UTIL_EXPORT std::string GetSoundsPath();
108 
116  TR_UTIL_EXPORT std::string GetParticlesPath();
117 
125  TR_UTIL_EXPORT std::string GetTexturesPath();
126 
134  TR_UTIL_EXPORT std::string GetTerrainsPath();
135 
143  TR_UTIL_EXPORT std::string GetShadersPath();
144 
152  TR_UTIL_EXPORT std::string GetGUIPath();
153 
161  TR_UTIL_EXPORT std::string GetConfigPath();
162 
171 
180 
188  TR_UTIL_EXPORT std::string GetUserSoundsPath();
189 
197  TR_UTIL_EXPORT std::string GetUserParticlesPath();
198 
206  TR_UTIL_EXPORT std::string GetUserTexturesPath();
207 
215  TR_UTIL_EXPORT std::string GetUserTerrainsPath();
216 
224  TR_UTIL_EXPORT std::string GetUserShadersPath();
225 
233  TR_UTIL_EXPORT std::string GetUserGUIPath();
234 
242  TR_UTIL_EXPORT std::string GetUserConfigPath();
243 
252  TR_UTIL_EXPORT std::string GetLogPath();
253 
261  TR_UTIL_EXPORT void SetDataFilePathList(const std::string& pathList);
262 
270  TR_UTIL_EXPORT std::string GetDataFilePathList();
271 
284  TR_UTIL_EXPORT std::string GetDataPath();
285 
294  TR_UTIL_EXPORT void SetDataPath(std::string& path);
295 
303 
311 
318 
327  TR_UTIL_EXPORT std::string GetRootPath();
328 
338  TR_UTIL_EXPORT std::string GetEnvironment(const std::string& env);
339 
349  TR_UTIL_EXPORT bool IsEnvironment(const std::string& env);
350 
359  TR_UTIL_EXPORT void SetEnvironment(const std::string& name, const std::string& value);
360 
371  TR_UTIL_EXPORT std::string FindFile(const std::string& fileName);
372 
388  TR_UTIL_EXPORT std::string FindFile(const std::string& fileName, std::vector<std::string> paths, bool caseInsensitive = true);
389 
390 #ifdef TR_APPLE
391 
400  std::string GetBundleResourcesPath();
401 
410  std::string GetBundlePlugInsPath();
411 
420  std::string GetBundlePath();
421 
430  void RemovePSNCommandLineOption(int& argc, char**& argv);
431 #else
432 
441  inline void RemovePSNCommandLineOption(int& /*argc*/, char**& /*argv*/) {}
442 #endif
443 }
444 
static const std::string TEXTURES_PATH("/Textures")
TR_UTIL_EXPORT std::string GetUserGUIPath()
Gets user graphical user interface path.
Definition: PathUtils.cpp:584
TR_UTIL_EXPORT std::string GetSkeletalMeshesPath()
Gets skeletal meshes path.
Definition: PathUtils.cpp:494
static const std::string SHADERS_PATH("/Shaders")
TR_UTIL_EXPORT std::string GetSoundsPath()
Gets sounds path.
Definition: PathUtils.cpp:500
TR_UTIL_EXPORT std::string GetDataPath()
Get the TR Data file path.
Definition: PathUtils.cpp:82
static const std::string DEFAULT_TR_FOLDER("/.trueReality")
TR_UTIL_EXPORT std::string GetDataFilePathList()
Get the list of data file paths.
Definition: PathUtils.cpp:277
TR_UTIL_EXPORT void SetDataFilePathList(const std::string &pathList)
Set the list of data file paths.
Definition: PathUtils.cpp:242
TR_UTIL_EXPORT std::string GetRootPath()
Get the root path to the engine (equivalent to the TR_ROOT environment) If the TR_ROOT environment is...
Definition: PathUtils.cpp:182
TR_UTIL_EXPORT std::string GetUserStaticMeshesPath()
Gets user static meshes path.
Definition: PathUtils.cpp:542
TR_UTIL_EXPORT std::string GetShadersPath()
Gets shaders path.
Definition: PathUtils.cpp:524
TR_UTIL_EXPORT void CreateDataPathTree()
Creates all the folders in the Data (TR_DATA) folder, that includes Maps, GUI, Shaders, StaticMeshes, etc etc.
Definition: PathUtils.cpp:126
TR_UTIL_EXPORT void CreateUserDataPathTree()
Creates all the folders in the Data (TR_USER_DATA) folder, that includes Maps, GUI, Shaders, StaticMeshes, etc etc.
Definition: PathUtils.cpp:147
TR_UTIL_EXPORT std::string GetUserDataPath()
Get the folder where TR will save and store User data files It is MyDocuments on Windows and the same...
Definition: PathUtils.cpp:219
static const std::string GUI_PATH("/GUI")
TR_UTIL_EXPORT std::string GetGUIPath()
Gets graphical user interface path.
Definition: PathUtils.cpp:530
TR_UTIL_EXPORT bool IsEnvironment(const std::string &env)
Is the supplied environment variable defined?
Definition: PathUtils.cpp:475
TR_UTIL_EXPORT std::string GetUserConfigPath()
Gets user configuration path.
Definition: PathUtils.cpp:590
TR_UTIL_EXPORT std::string GetStaticMeshesPath()
Gets static meshes path.
Definition: PathUtils.cpp:488
TR_UTIL_EXPORT std::string GetEnvironment(const std::string &env)
Convenience method to get the supplied environment variable.
Definition: PathUtils.cpp:347
TR_UTIL_EXPORT std::string GetTerrainsPath()
Gets terrain path.
Definition: PathUtils.cpp:518
static const std::string STATIC_MESHES_PATH("/StaticMeshes")
TR_UTIL_EXPORT std::string GetConfigPath()
Gets configuration path.
Definition: PathUtils.cpp:536
TR_UTIL_EXPORT std::string GetUserParticlesPath()
Gets user particles path.
Definition: PathUtils.cpp:560
TR_UTIL_EXPORT std::string GetUserSoundsPath()
Gets user sounds path.
Definition: PathUtils.cpp:554
A class that represents date time utility.
TR_UTIL_EXPORT std::string GetLogPath()
Get the folder where TR will save and store the log files It is the same as GetUserDataPath() by defa...
Definition: PathUtils.cpp:206
static const std::string SOUNDS_PATH("/Sounds")
void RemovePSNCommandLineOption(int &, char **&)
Removes the psn command line option.
Definition: PathUtils.h:441
TR_UTIL_EXPORT std::string GetParticlesPath()
Gets particles path.
Definition: PathUtils.cpp:506
TR_UTIL_EXPORT std::string GetUserTexturesPath()
Gets user textures path.
Definition: PathUtils.cpp:566
TR_UTIL_EXPORT void SetEnvironment(const std::string &name, const std::string &value)
Sets an environment variable.
Definition: PathUtils.cpp:371
static const std::string PARTICLES_PATH("/Particles")
TR_UTIL_EXPORT void SetDataPath(std::string &path)
Overwrites the Data path.
Definition: PathUtils.cpp:120
static const std::string TERRAINS_PATH("/Terrains")
TR_UTIL_EXPORT std::string GetUserHomeDirectory()
Get the USER Home directory.
Definition: PathUtils.cpp:58
static const std::string DATA_PATH_DEFAULT("/Data")
TR_UTIL_EXPORT std::string GetTexturesPath()
Gets textures path.
Definition: PathUtils.cpp:512
static const std::string SKELETAL_MESHES_PATH("/SkeletalMeshes")
TR_UTIL_EXPORT std::string GetUserShadersPath()
Gets user shaders path.
Definition: PathUtils.cpp:578
TR_UTIL_EXPORT std::string FindFile(const std::string &fileName)
Searches for a file in the list of paths found by calling GetDataFilePathList()
Definition: PathUtils.cpp:304
TR_UTIL_EXPORT void CreateDataPathTrees()
Convenience function that calls CreateDataPathTree() and CreateUserDataPathTree();.
Definition: PathUtils.cpp:168
TR_UTIL_EXPORT std::string GetUserTerrainsPath()
Gets user terrain path.
Definition: PathUtils.cpp:572
TR_UTIL_EXPORT std::string GetUserSkeletalMeshesPath()
Gets user skeletal meshes path.
Definition: PathUtils.cpp:548
static const std::string CONFIG_PATH("/Config")