TrueReality  v0.1.1912
trUtil::PathUtils Namespace Reference

Functions

static const std::string DEFAULT_TR_FOLDER ("/.trueReality")
 
static const std::string DATA_PATH_DEFAULT ("/Data")
 
static const std::string STATIC_MESHES_PATH ("/StaticMeshes")
 
static const std::string SKELETAL_MESHES_PATH ("/SkeletalMeshes")
 
static const std::string SOUNDS_PATH ("/Sounds")
 
static const std::string PARTICLES_PATH ("/Particles")
 
static const std::string TEXTURES_PATH ("/Textures")
 
static const std::string TERRAINS_PATH ("/Terrains")
 
static const std::string SHADERS_PATH ("/Shaders")
 
static const std::string GUI_PATH ("/GUI")
 
static const std::string CONFIG_PATH ("/Config")
 
TR_UTIL_EXPORT std::string GetUserHomeDirectory ()
 Get the USER Home directory. More...
 
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 as GetHomeDirectory() on Linux and Apple If TR_USER_DATA Environmental variable is defined, it will return the path in TR_USER_DATA. More...
 
TR_UTIL_EXPORT std::string GetStaticMeshesPath ()
 Gets static meshes path. More...
 
TR_UTIL_EXPORT std::string GetSkeletalMeshesPath ()
 Gets skeletal meshes path. More...
 
TR_UTIL_EXPORT std::string GetSoundsPath ()
 Gets sounds path. More...
 
TR_UTIL_EXPORT std::string GetParticlesPath ()
 Gets particles path. More...
 
TR_UTIL_EXPORT std::string GetTexturesPath ()
 Gets textures path. More...
 
TR_UTIL_EXPORT std::string GetTerrainsPath ()
 Gets terrain path. More...
 
TR_UTIL_EXPORT std::string GetShadersPath ()
 Gets shaders path. More...
 
TR_UTIL_EXPORT std::string GetGUIPath ()
 Gets graphical user interface path. More...
 
TR_UTIL_EXPORT std::string GetConfigPath ()
 Gets configuration path. More...
 
TR_UTIL_EXPORT std::string GetUserStaticMeshesPath ()
 Gets user static meshes path. More...
 
TR_UTIL_EXPORT std::string GetUserSkeletalMeshesPath ()
 Gets user skeletal meshes path. More...
 
TR_UTIL_EXPORT std::string GetUserSoundsPath ()
 Gets user sounds path. More...
 
TR_UTIL_EXPORT std::string GetUserParticlesPath ()
 Gets user particles path. More...
 
TR_UTIL_EXPORT std::string GetUserTexturesPath ()
 Gets user textures path. More...
 
TR_UTIL_EXPORT std::string GetUserTerrainsPath ()
 Gets user terrain path. More...
 
TR_UTIL_EXPORT std::string GetUserShadersPath ()
 Gets user shaders path. More...
 
TR_UTIL_EXPORT std::string GetUserGUIPath ()
 Gets user graphical user interface path. More...
 
TR_UTIL_EXPORT std::string GetUserConfigPath ()
 Gets user configuration path. More...
 
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 default, unless the variable TR_LOG_PATH is set. More...
 
TR_UTIL_EXPORT void SetDataFilePathList (const std::string &pathList)
 Set the list of data file paths. More...
 
TR_UTIL_EXPORT std::string GetDataFilePathList ()
 Get the list of data file paths. More...
 
TR_UTIL_EXPORT std::string GetDataPath ()
 Get the TR Data file path. More...
 
TR_UTIL_EXPORT void SetDataPath (std::string &path)
 Overwrites the Data path. More...
 
TR_UTIL_EXPORT void CreateDataPathTree ()
 Creates all the folders in the Data (TR_DATA) folder, that includes Maps, GUI, Shaders, StaticMeshes, etc etc. More...
 
TR_UTIL_EXPORT void CreateUserDataPathTree ()
 Creates all the folders in the Data (TR_USER_DATA) folder, that includes Maps, GUI, Shaders, StaticMeshes, etc etc. More...
 
TR_UTIL_EXPORT void CreateDataPathTrees ()
 Convenience function that calls CreateDataPathTree() and CreateUserDataPathTree();. More...
 
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 not set, the local directory will be returned. More...
 
TR_UTIL_EXPORT std::string GetEnvironment (const std::string &env)
 Convenience method to get the supplied environment variable. More...
 
TR_UTIL_EXPORT bool IsEnvironment (const std::string &env)
 Is the supplied environment variable defined? More...
 
TR_UTIL_EXPORT void SetEnvironment (const std::string &name, const std::string &value)
 Sets an environment variable. More...
 
TR_UTIL_EXPORT std::string FindFile (const std::string &fileName)
 Searches for a file in the list of paths found by calling GetDataFilePathList() More...
 
TR_UTIL_EXPORT std::string FindFile (const std::string &fileName, std::vector< std::string > paths, bool caseInsensitive=true)
 Searches a given path list for a file name. More...
 
void RemovePSNCommandLineOption (int &, char **&)
 Removes the psn command line option. More...
 

Variables

static OpenThreads::Mutex gDatapathMutex
 
static std::string mDataPath = trUtil::StringUtils::STR_BLANK
 

Function Documentation

◆ CONFIG_PATH()

static const std::string trUtil::PathUtils::CONFIG_PATH ( "/Config"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetConfigPath(), and GetUserConfigPath().

Here is the caller graph for this function:

◆ CreateDataPathTree()

void trUtil::PathUtils::CreateDataPathTree ( )

Creates all the folders in the Data (TR_DATA) folder, that includes Maps, GUI, Shaders, StaticMeshes, etc etc.

Definition at line 126 of file PathUtils.cpp.

References CONFIG_PATH(), GetDataPath(), trUtil::FileUtils::GetInstance(), GUI_PATH(), trUtil::Exception::LogException(), trUtil::FileUtils::MakeDirectoryEX(), PARTICLES_PATH(), SHADERS_PATH(), SKELETAL_MESHES_PATH(), SOUNDS_PATH(), STATIC_MESHES_PATH(), TERRAINS_PATH(), and TEXTURES_PATH().

Referenced by CreateDataPathTrees().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateDataPathTrees()

void trUtil::PathUtils::CreateDataPathTrees ( )

Convenience function that calls CreateDataPathTree() and CreateUserDataPathTree();.

Definition at line 168 of file PathUtils.cpp.

References CreateDataPathTree(), CreateUserDataPathTree(), and trUtil::Exception::LogException().

Here is the call graph for this function:

◆ CreateUserDataPathTree()

void trUtil::PathUtils::CreateUserDataPathTree ( )

Creates all the folders in the Data (TR_USER_DATA) folder, that includes Maps, GUI, Shaders, StaticMeshes, etc etc.

Definition at line 147 of file PathUtils.cpp.

References CONFIG_PATH(), trUtil::FileUtils::GetInstance(), GetUserDataPath(), GUI_PATH(), trUtil::Exception::LogException(), trUtil::FileUtils::MakeDirectoryEX(), PARTICLES_PATH(), SHADERS_PATH(), SKELETAL_MESHES_PATH(), SOUNDS_PATH(), STATIC_MESHES_PATH(), TERRAINS_PATH(), and TEXTURES_PATH().

Referenced by CreateDataPathTrees(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DATA_PATH_DEFAULT()

static const std::string trUtil::PathUtils::DATA_PATH_DEFAULT ( "/Data"  )
static

Referenced by GetDataPath().

Here is the caller graph for this function:

◆ DEFAULT_TR_FOLDER()

static const std::string trUtil::PathUtils::DEFAULT_TR_FOLDER ( "/.trueReality"  )
static

Referenced by GetUserDataPath().

Here is the caller graph for this function:

◆ FindFile() [1/2]

std::string trUtil::PathUtils::FindFile ( const std::string &  fileName)

Searches for a file in the list of paths found by calling GetDataFilePathList()

Parameters
fileNameCan be a single filename or a path and file name relative to the current engines data path list.
Returns
The full path to the file requested or empty string if it's not found.

Definition at line 304 of file PathUtils.cpp.

◆ FindFile() [2/2]

std::string trUtil::PathUtils::FindFile ( const std::string &  fileName,
std::vector< std::string >  paths,
bool  caseInsensitive = true 
)

Searches a given path list for a file name.

Parameters
fileNameCan be a single filename or a path and file name relative to the current engines data path list.
pathsthe list of file paths to search.
caseInsensitive(Optional) If the search should be case insensitive. This only works around case-sensitive file systems, it cannot not make a search fail if the case is wrong on a case insensitive one and one sets it to false.
Returns
The found file.

Definition at line 323 of file PathUtils.cpp.

References trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileName, trUtil::FileInfo::fileType, trUtil::FileUtils::GetFileInfo(), trUtil::FileUtils::GetInstance(), and trUtil::FileUtils::PATH_SEPARATOR.

Here is the call graph for this function:

◆ GetConfigPath()

std::string trUtil::PathUtils::GetConfigPath ( )

Gets configuration path.

Returns
The configuration path.

Definition at line 536 of file PathUtils.cpp.

References CONFIG_PATH(), and GetDataPath().

Here is the call graph for this function:

◆ GetDataFilePathList()

std::string trUtil::PathUtils::GetDataFilePathList ( )

Get the list of data file paths.

Returns
The data file path list.

Definition at line 277 of file PathUtils.cpp.

◆ GetDataPath()

std::string trUtil::PathUtils::GetDataPath ( )

Get the TR Data file path.

This comes directly from the environment variable "TR_DATA", if it wasn't overwritten by the user. If the environment variable is not set, TR_ROOT/Data directory will be returned.

Todo:
need to decide how paths will be handled. We need to decide if TR_DATA is a list or a single item.
Returns
The data path.

Definition at line 82 of file PathUtils.cpp.

References DATA_PATH_DEFAULT(), GetEnvironment(), GetRootPath(), IsEnvironment(), mDataPath, trUtil::StringUtils::STR_BLANK(), and trUtil::EnvVariables::TR_DATA.

Referenced by CreateDataPathTree(), GetConfigPath(), GetGUIPath(), GetParticlesPath(), GetShadersPath(), GetSkeletalMeshesPath(), GetSoundsPath(), GetStaticMeshesPath(), GetTerrainsPath(), and GetTexturesPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEnvironment()

std::string trUtil::PathUtils::GetEnvironment ( const std::string &  env)

Convenience method to get the supplied environment variable.

Parameters
envThe environment.
Returns
The environment.

Definition at line 347 of file PathUtils.cpp.

Referenced by GetDataPath(), GetLogPath(), GetRootPath(), and GetUserDataPath().

Here is the caller graph for this function:

◆ GetGUIPath()

std::string trUtil::PathUtils::GetGUIPath ( )

Gets graphical user interface path.

Returns
The graphical user interface path.

Definition at line 530 of file PathUtils.cpp.

References GetDataPath(), and GUI_PATH().

Here is the call graph for this function:

◆ GetLogPath()

std::string trUtil::PathUtils::GetLogPath ( )

Get the folder where TR will save and store the log files It is the same as GetUserDataPath() by default, unless the variable TR_LOG_PATH is set.

Returns
The log path.

Definition at line 206 of file PathUtils.cpp.

References GetEnvironment(), GetUserDataPath(), IsEnvironment(), and trUtil::EnvVariables::TR_LOG_PATH.

Referenced by trUtil::Logging::LogWriterFile::OpenFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetParticlesPath()

std::string trUtil::PathUtils::GetParticlesPath ( )

Gets particles path.

Returns
The particles path.

Definition at line 506 of file PathUtils.cpp.

References GetDataPath(), and PARTICLES_PATH().

Here is the call graph for this function:

◆ GetRootPath()

std::string trUtil::PathUtils::GetRootPath ( )

Get the root path to the engine (equivalent to the TR_ROOT environment) If the TR_ROOT environment is not set, the local directory will be returned.

Returns
The root path.

Definition at line 182 of file PathUtils.cpp.

References GetEnvironment(), IsEnvironment(), and trUtil::EnvVariables::TR_ROOT.

Referenced by GetDataPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetShadersPath()

std::string trUtil::PathUtils::GetShadersPath ( )

Gets shaders path.

Returns
The shaders path.

Definition at line 524 of file PathUtils.cpp.

References GetDataPath(), and SHADERS_PATH().

Here is the call graph for this function:

◆ GetSkeletalMeshesPath()

std::string trUtil::PathUtils::GetSkeletalMeshesPath ( )

Gets skeletal meshes path.

Returns
The skeletal meshes path.

Definition at line 494 of file PathUtils.cpp.

References GetDataPath(), and SKELETAL_MESHES_PATH().

Here is the call graph for this function:

◆ GetSoundsPath()

std::string trUtil::PathUtils::GetSoundsPath ( )

Gets sounds path.

Returns
The sounds path.

Definition at line 500 of file PathUtils.cpp.

References GetDataPath(), and SOUNDS_PATH().

Here is the call graph for this function:

◆ GetStaticMeshesPath()

std::string trUtil::PathUtils::GetStaticMeshesPath ( )

Gets static meshes path.

Returns
The static meshes path.

Definition at line 488 of file PathUtils.cpp.

References GetDataPath(), and STATIC_MESHES_PATH().

Referenced by trCore::SceneObjects::RingArray::LoadModels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTerrainsPath()

std::string trUtil::PathUtils::GetTerrainsPath ( )

Gets terrain path.

Returns
The terrain path.

Definition at line 518 of file PathUtils.cpp.

References GetDataPath(), and TERRAINS_PATH().

Here is the call graph for this function:

◆ GetTexturesPath()

std::string trUtil::PathUtils::GetTexturesPath ( )

Gets textures path.

Returns
The textures path.

Definition at line 512 of file PathUtils.cpp.

References GetDataPath(), and TEXTURES_PATH().

Here is the call graph for this function:

◆ GetUserConfigPath()

std::string trUtil::PathUtils::GetUserConfigPath ( )

Gets user configuration path.

Returns
The user configuration path.

Definition at line 590 of file PathUtils.cpp.

References CONFIG_PATH(), and GetUserDataPath().

Referenced by trUtil::JSON::File::File().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUserDataPath()

std::string trUtil::PathUtils::GetUserDataPath ( )

Get the folder where TR will save and store User data files It is MyDocuments on Windows and the same as GetHomeDirectory() on Linux and Apple If TR_USER_DATA Environmental variable is defined, it will return the path in TR_USER_DATA.

Returns
The user data path.

Definition at line 219 of file PathUtils.cpp.

References DEFAULT_TR_FOLDER(), GetEnvironment(), GetUserHomeDirectory(), IsEnvironment(), MAX_PATH, and trUtil::EnvVariables::TR_USER_DATA.

Referenced by CreateUserDataPathTree(), GetLogPath(), GetUserConfigPath(), GetUserGUIPath(), GetUserParticlesPath(), GetUserShadersPath(), GetUserSkeletalMeshesPath(), GetUserSoundsPath(), GetUserStaticMeshesPath(), GetUserTerrainsPath(), and GetUserTexturesPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUserGUIPath()

std::string trUtil::PathUtils::GetUserGUIPath ( )

Gets user graphical user interface path.

Returns
The user graphical user interface path.

Definition at line 584 of file PathUtils.cpp.

References GetUserDataPath(), and GUI_PATH().

Here is the call graph for this function:

◆ GetUserHomeDirectory()

std::string trUtil::PathUtils::GetUserHomeDirectory ( )

Get the USER Home directory.

Returns
The home directory.

Definition at line 58 of file PathUtils.cpp.

References MAX_PATH.

Referenced by GetUserDataPath().

Here is the caller graph for this function:

◆ GetUserParticlesPath()

std::string trUtil::PathUtils::GetUserParticlesPath ( )

Gets user particles path.

Returns
The user particles path.

Definition at line 560 of file PathUtils.cpp.

References GetUserDataPath(), and PARTICLES_PATH().

Here is the call graph for this function:

◆ GetUserShadersPath()

std::string trUtil::PathUtils::GetUserShadersPath ( )

Gets user shaders path.

Returns
The user shaders path.

Definition at line 578 of file PathUtils.cpp.

References GetUserDataPath(), and SHADERS_PATH().

Here is the call graph for this function:

◆ GetUserSkeletalMeshesPath()

std::string trUtil::PathUtils::GetUserSkeletalMeshesPath ( )

Gets user skeletal meshes path.

Returns
The user skeletal meshes path.

Definition at line 548 of file PathUtils.cpp.

References GetUserDataPath(), and SKELETAL_MESHES_PATH().

Here is the call graph for this function:

◆ GetUserSoundsPath()

std::string trUtil::PathUtils::GetUserSoundsPath ( )

Gets user sounds path.

Returns
The user sounds path.

Definition at line 554 of file PathUtils.cpp.

References GetUserDataPath(), and SOUNDS_PATH().

Here is the call graph for this function:

◆ GetUserStaticMeshesPath()

std::string trUtil::PathUtils::GetUserStaticMeshesPath ( )

Gets user static meshes path.

Returns
The user static meshes path.

Definition at line 542 of file PathUtils.cpp.

References GetUserDataPath(), and STATIC_MESHES_PATH().

Here is the call graph for this function:

◆ GetUserTerrainsPath()

std::string trUtil::PathUtils::GetUserTerrainsPath ( )

Gets user terrain path.

Returns
The user terrain path.

Definition at line 572 of file PathUtils.cpp.

References GetUserDataPath(), and TERRAINS_PATH().

Here is the call graph for this function:

◆ GetUserTexturesPath()

std::string trUtil::PathUtils::GetUserTexturesPath ( )

Gets user textures path.

Returns
The user textures path.

Definition at line 566 of file PathUtils.cpp.

References GetUserDataPath(), and TEXTURES_PATH().

Here is the call graph for this function:

◆ GUI_PATH()

static const std::string trUtil::PathUtils::GUI_PATH ( "/GUI"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetGUIPath(), and GetUserGUIPath().

Here is the caller graph for this function:

◆ IsEnvironment()

bool trUtil::PathUtils::IsEnvironment ( const std::string &  env)

Is the supplied environment variable defined?

Parameters
envThe environment.
Returns
True if environment, false if not.

Definition at line 475 of file PathUtils.cpp.

Referenced by GetDataPath(), GetLogPath(), GetRootPath(), and GetUserDataPath().

Here is the caller graph for this function:

◆ PARTICLES_PATH()

static const std::string trUtil::PathUtils::PARTICLES_PATH ( "/Particles"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetParticlesPath(), and GetUserParticlesPath().

Here is the caller graph for this function:

◆ RemovePSNCommandLineOption()

void trUtil::PathUtils::RemovePSNCommandLineOption ( int &  argc,
char **&  argv 
)
inline

Removes the psn command line option.

Parameters
[in,out]argcThe argc.
[in,out]argv[in,out] If non-null, the argv.

Definition at line 441 of file PathUtils.h.

Referenced by SetEnvironment().

Here is the caller graph for this function:

◆ SetDataFilePathList()

void trUtil::PathUtils::SetDataFilePathList ( const std::string &  pathList)

Set the list of data file paths.

Parameters
pathListList of paths.

Definition at line 242 of file PathUtils.cpp.

References LOG_W.

◆ SetDataPath()

void trUtil::PathUtils::SetDataPath ( std::string &  path)

Overwrites the Data path.

If this is set, TR will ignore the TR_DATA variable and use the passed in value instead.

Parameters
[in,out]pathFull pathname of the file.

Definition at line 120 of file PathUtils.cpp.

◆ SetEnvironment()

void trUtil::PathUtils::SetEnvironment ( const std::string &  name,
const std::string &  value 
)

Sets an environment variable.

Parameters
namethe name of the variable to set.
valuethe value of the environment variable to set.

Definition at line 371 of file PathUtils.cpp.

References RemovePSNCommandLineOption().

Here is the call graph for this function:

◆ SHADERS_PATH()

static const std::string trUtil::PathUtils::SHADERS_PATH ( "/Shaders"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetShadersPath(), and GetUserShadersPath().

Here is the caller graph for this function:

◆ SKELETAL_MESHES_PATH()

static const std::string trUtil::PathUtils::SKELETAL_MESHES_PATH ( "/SkeletalMeshes"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetSkeletalMeshesPath(), and GetUserSkeletalMeshesPath().

Here is the caller graph for this function:

◆ SOUNDS_PATH()

static const std::string trUtil::PathUtils::SOUNDS_PATH ( "/Sounds"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetSoundsPath(), and GetUserSoundsPath().

Here is the caller graph for this function:

◆ STATIC_MESHES_PATH()

static const std::string trUtil::PathUtils::STATIC_MESHES_PATH ( "/StaticMeshes"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetStaticMeshesPath(), and GetUserStaticMeshesPath().

Here is the caller graph for this function:

◆ TERRAINS_PATH()

static const std::string trUtil::PathUtils::TERRAINS_PATH ( "/Terrains"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetTerrainsPath(), and GetUserTerrainsPath().

Here is the caller graph for this function:

◆ TEXTURES_PATH()

static const std::string trUtil::PathUtils::TEXTURES_PATH ( "/Textures"  )
static

Referenced by CreateDataPathTree(), CreateUserDataPathTree(), GetTexturesPath(), and GetUserTexturesPath().

Here is the caller graph for this function:

Variable Documentation

◆ gDatapathMutex

OpenThreads::Mutex trUtil::PathUtils::gDatapathMutex
static

Definition at line 53 of file PathUtils.cpp.

◆ mDataPath

std::string trUtil::PathUtils::mDataPath = trUtil::StringUtils::STR_BLANK
static

Definition at line 55 of file PathUtils.cpp.

Referenced by GetDataPath().