CoriEngine
Loading...
Searching...
No Matches
Cori::FileSystem::PathManager Class Reference

Path manager is responsible for loading the fsgame.json file from the drive, parsing it, and providing paths based on aliases. More...

#include <PathManager.hpp>

Static Public Member Functions

static std::filesystem::path GetAliasedPath (const std::string &alias)
 Retries the full aliased path defined in fsgame.json.
static std::filesystem::path GetAliasedPath (const std::string_view alias)
 Retries the full aliased path defined in fsgame.json.
static std::filesystem::path GetAliasedPath (const char *alias)
 Retries the full aliased path defined in fsgame.json.

Detailed Description

Path manager is responsible for loading the fsgame.json file from the drive, parsing it, and providing paths based on aliases.

Example of fsgame.json:

{
"paths": [
{
"alias": "APP_ROOT",
"path": "../../",
"root": "BIN"
},
{
"alias": "ENGINE_ROOT",
"path": "CoriEngine/Engine",
"root": "APP_ROOT"
},
{
"alias": "ENGINE_DATA",
"path": "enginedata",
"root": "ENGINE_ROOT"
},
{
"alias": "USER_DATA",
"path": "userdata",
"root": "APP_ROOT"
},
{
"alias": "ASSETS",
"path": "assets",
"root": "APP_ROOT"
},
{
"alias": "FONTS",
"path": "fonts",
"root": "ASSETS"
},
{
"alias": "LEVELS",
"path": "levels",
"root": "ASSETS"
},
{
"alias": "SOUNDS",
"path": "sounds",
"root": "ASSETS"
},
{
"alias": "TEXTURES",
"path": "textures",
"root": "ASSETS"
}
]
}

By default you have alias 'BIN' defined, it points to the directory of the binary executable of your app. Cori expects you to define 'ENGINE_DATA' alias, it should point to the 'enginedata' path in the engine root folder, and a 'USER_DATA' alias to some folder that will hold saves (engine saves the last window and screen mode there)
Let's examine how to define aliases correctly:

{
"alias": "ASSETS",
// This the name of the alias, it is used to retrieve the alias from the code
// (with the GetAliasedPath method of this class) and to be a root for other alias defines
// later on in the json file.
"path": "assets",
// Folder inside the 'root' alias path to point to.
"root": "APP_ROOT"
// Alias that we will use as the root directory for out new alias.
}

When defining aliases you need to make sure the alias that you're trying to use as 'root' alias is defined above.
Example:
Incorrect:

{
"alias": "ENGINE_ROOT",
"path": "CoriEngine/Engine",
"root": "APP_ROOT"
},
{
"alias": "APP_ROOT",
"path": "../../",
"root": "BIN"
}

Correct:

{
"alias": "APP_ROOT",
"path": "../../",
"root": "BIN"
},
{
"alias": "ENGINE_ROOT",
"path": "CoriEngine/Engine",
"root": "APP_ROOT"
}
Note
fsgame.json is expected to be 1 directory lower than the binary directory with the app executable.

Definition at line 111 of file PathManager.hpp.

Member Function Documentation

◆ GetAliasedPath() [1/3]

std::filesystem::path Cori::FileSystem::PathManager::GetAliasedPath ( const char * alias)
static

Retries the full aliased path defined in fsgame.json.

Parameters
aliasAlias name to retrieve.
Returns
If the alias exist it returns the full path taking into account alias root, if an alias is not found it will return an empty path.

Definition at line 35 of file PathManager.cpp.

Here is the call graph for this function:

◆ GetAliasedPath() [2/3]

std::filesystem::path Cori::FileSystem::PathManager::GetAliasedPath ( const std::string & alias)
static

Retries the full aliased path defined in fsgame.json.

Parameters
aliasAlias name to retrieve.
Returns
If the alias exist it returns the full path taking into account alias root, if an alias is not found it will return an empty path.

Definition at line 7 of file PathManager.cpp.

Here is the call graph for this function:

◆ GetAliasedPath() [3/3]

std::filesystem::path Cori::FileSystem::PathManager::GetAliasedPath ( const std::string_view alias)
static

Retries the full aliased path defined in fsgame.json.

Parameters
aliasAlias name to retrieve.
Returns
If the alias exist it returns the full path taking into account alias root, if an alias is not found it will return an empty path.

Definition at line 21 of file PathManager.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: