utility::platform::file namespace

file i/o and manpulations utilities namespace

functions

exists
checks if the given path points to a file or not.
public
erase
erases the file ath the given path.
public static
read
reads the given filepath's contents into a psl::char_t container.
public
read
reads the given filepath's contents into a psl::string container.
public
read
reads the given filepath's contents into a psl::string container on success.
public static
write
write the contents to the given location on the filesystem.
public
to_unix
transforms the given path to the unix format.
public static
to_windows
transforms the given path to the windows format.
public static
to_platform
transforms the given path to the current platforms format.
public static
to_generic
transforms the given path to the application wide standard format.
public static

Function documentation

bool utility::platform::file::exists(psl::string_view filename)

Brief

checks if the given path points to a file or not.

Details

checks if the given path points to a file or not. This path can be relative to the current working directory, usually the app root is the working directory, or an absolute path.

Parameters
filename in the path to the file to check.
Returns true in case the target is indeed a file, otherwise in all scenarios it returns false.

static bool utility::platform::file::erase(psl::string_view filename)

Brief

erases the file ath the given path.

Details

Parameters
filename in the path to the file.
Returns true in case the file was successfuly erased.

bool utility::platform::file::read(psl::string_view filename, std::vector<psl::char_t>& out, size_t count = std::numeric_limits<size_t>::max())

Brief

reads the given filepath's contents into a psl::char_t container.

Details

Parameters
filename in the path to the file.
out in/out the output container to read into.
count
Returns true on successfuly reading the file. This can be false in case something went wrong.

bool utility::platform::file::read(psl::string_view filename, psl::string& out, size_t count = std::numeric_limits<size_t>::max())

Brief

reads the given filepath's contents into a psl::string container.

Details

Parameters
filename in the path to the file.
out in/out the output container to read into.
count
Returns true on successfuly reading the file. This can be false in case something went wrong.

static std::optional<psl::string> utility::platform::file::read(psl::string_view filename, size_t count = std::numeric_limits<size_t>::max())

Brief

reads the given filepath's contents into a psl::string container on success.

Details

Parameters
filename in the path to the file.
count
Returns a psl::string on success, and a std::nullopt on failure.

bool utility::platform::file::write(psl::string_view filename, psl::string_view content)

Brief

write the contents to the given location on the filesystem.

Parameters
filename in the path to the target location.
content in the content to write at the given location.
Returns true when the content has successfully been written at the target location.

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

Brief

transforms the given path to the unix format.

Parameters
path in the path to transform.
Returns the transformed path.

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

Brief

transforms the given path to the windows format.

Parameters
path in the path to transform.
Returns the transformed path.

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

Brief

transforms the given path to the current platforms format.

Parameters
path in the path to transform.
Returns the transformed path.

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

Brief

transforms the given path to the application wide standard format.

Parameters
path in the path to transform.
Returns the transformed path.