Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
filesystem_utils.h File Reference

Declares filesystem utility helpers. More...

#include <cstdint>
#include <string>
#include <string_view>
Include dependency graph for filesystem_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool platform::ensure_directory_exists (const std::string &directoryPath, std::string *errorMessage=nullptr)
 Ensure that a directory path exists, creating missing segments as needed.
 
std::string platform::file_name_from_path (std::string_view path)
 Return the last path component from a file path.
 
bool platform::is_path_separator (char character)
 Return whether a character is recognized as a path separator.
 
std::string platform::join_path (const std::string &left, const std::string &right)
 Join two path components using the preferred platform separator.
 
std::string platform::parent_directory (std::string_view filePath)
 Return the parent directory portion of a file path.
 
bool platform::path_has_prefix (const std::string &path, const std::string &prefix)
 Return whether a path begins with the requested prefix.
 
char platform::preferred_path_separator ()
 Return the preferred path separator for the active platform.
 
bool platform::try_get_file_size (std::string_view path, std::uint64_t *sizeBytes=nullptr)
 Try to read the size of a regular file.
 

Detailed Description

Declares filesystem utility helpers.

Function Documentation

◆ ensure_directory_exists()

bool platform::ensure_directory_exists ( const std::string & directoryPath,
std::string * errorMessage = nullptr )

Ensure that a directory path exists, creating missing segments as needed.

Parameters
directoryPathDirectory path to create.
errorMessageOptional output for creation failures.
Returns
True when the directory exists or was created successfully.

◆ file_name_from_path()

std::string platform::file_name_from_path ( std::string_view path)

Return the last path component from a file path.

Parameters
pathPath to inspect.
Returns
Final path component, or the original string when no separator exists.

◆ is_path_separator()

bool platform::is_path_separator ( char character)

Return whether a character is recognized as a path separator.

Parameters
characterCharacter to inspect.
Returns
True when the character is a supported path separator.

◆ join_path()

std::string platform::join_path ( const std::string & left,
const std::string & right )

Join two path components using the preferred platform separator.

Parameters
leftLeft path component.
rightRight path component.
Returns
Joined path.

◆ parent_directory()

std::string platform::parent_directory ( std::string_view filePath)

Return the parent directory portion of a file path.

Parameters
filePathFile path to inspect.
Returns
Parent directory path, or an empty string when none exists.

◆ path_has_prefix()

bool platform::path_has_prefix ( const std::string & path,
const std::string & prefix )

Return whether a path begins with the requested prefix.

Parameters
pathFull path to inspect.
prefixPrefix to compare against.
Returns
True when the path starts with the prefix.

◆ preferred_path_separator()

char platform::preferred_path_separator ( )

Return the preferred path separator for the active platform.

Returns
Preferred path separator character.

◆ try_get_file_size()

bool platform::try_get_file_size ( std::string_view path,
std::uint64_t * sizeBytes = nullptr )

Try to read the size of a regular file.

Parameters
pathFile path to inspect.
sizeBytesOptional output for the file size in bytes.
Returns
True when the path exists and is a regular file.