utility::platform::directory class

helper class that contains directory specific I/O manipulation methods and platform utilities.

static variables

seperator
the seperator character that all commands will be assumed to use, and all platform specific commands will be translated to/from
constexprconstexprpublicpublicstaticstatic
current_symbol
identifier that signifies the "current location" symbol in a file path.
constexprconstexprpublicpublicstaticstatic
parent_symbol
identifier that signifies the "go up one location" symbol in a file path.
constexprconstexprpublicpublicstaticstatic

static member functions

to_unix
translated the given path to one that is accepted on Unix systems
public static
to_windows
translated the given path to one that is accepted on Windows systems
public static
to_platform
translated the given path to one that is accepted on the current platform
public static
to_generic
translates the given path to the default path encoding that is used across this application as the standard.
public static
is_directory
checks if the given path is a directory.
public static
sanitize
sanitizes the seperators into the application wide standard one.
public static
erase
tries to erase/delete the given item this path points to.
public static
exists
checks if the given path (absolute) points to a directory or not.
public static
create
creates a directory that satisfies this path.
public static
all_files
gets all files in the target directory, no folders.
public static

Function documentation

static psl::string utility::platform::directory::to_unix(psl::string_view path)

Brief

translated the given path to one that is accepted on Unix systems

Parameters
path in the path to translate to one that works in unix systems.
Returns a string that should work on unix systems, and satisfies the requirements.

static psl::string utility::platform::directory::to_windows(psl::string_view path)

Brief

translated the given path to one that is accepted on Windows systems

Parameters
path in the path to translate to one that works in Windows systems.
Returns a string that should work on Windows systems, and satisfies the requirements.

static psl::string utility::platform::directory::to_platform(psl::string_view path)

Brief

translated the given path to one that is accepted on the current platform

Parameters
path in the path to translate to one that works on the current platform.
Returns a string that should work on the current platform, and satisfies the requirements.

static psl::string utility::platform::directory::to_generic(psl::string_view path)

Brief

translates the given path to the default path encoding that is used across this application as the standard.

Parameters
path in the path to translate.
Returns a string that is translated to the application-wide standard encoding (unix).

static bool utility::platform::directory::is_directory(psl::string_view path)

Brief

checks if the given path is a directory.

Details

Parameters
path in the path to check.
Returns true in case it is a directory.

static psl::string utility::platform::directory::sanitize(psl::string_view path)

Brief

sanitizes the seperators into the application wide standard one.

Parameters
path in the path to sanitize.
Returns the transformed input path.

static bool utility::platform::directory::erase(psl::string_view path)

Brief

tries to erase/delete the given item this path points to.

Details

tries to delete the file this path points to, or the folder this path points to.

Parameters
path in the path to what you wish to be erased.
Returns true if erasing the target item is successful.

static bool utility::platform::directory::exists(psl::string_view absolutePath)

Brief

checks if the given path (absolute) points to a directory or not.

Parameters
absolutePath in the path to check.
Returns true in case this path is valid and points to a directory.

static bool utility::platform::directory::create(psl::string_view absolutePath, bool recursive = false)

Brief

creates a directory that satisfies this path.

Parameters
absolutePath in the path to create the directory at.
recursive in should we make all non-existing parent directories as well (true) or fail (false) when the path to the given directory does not exist?
Returns true if the path is now fully valid and the directory exists.

static std::vector<psl::string> utility::platform::directory::all_files(psl::string_view target_directory, bool recursive)

Brief

gets all files in the target directory, no folders.

Details

gets all files in the target directory exluding the sub-directories. It however can recursively walk the sub-directories when needed, it will only return their contained items though.

Parameters
target_directory in the directory to run a search from.
recursive in should we also search the sub-directories (true), or not (false).
Returns a container of elements of the type psl::string, of all found items, that are transformed to the generic path format.