galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::fileutils Namespace Reference

Functions

std::expected< std::string, FileError > extension (const std::string &filepath) noexcept
 Get a file or path's extension.
std::expected< std::string, FileError > read (const std::string &filepath)
 Read a non-binary file on disk.
std::expected< bool, FileError > write (const std::string &filepath, const std::string &data)
 Writes a non-binary file to disk.
std::expected< nlohmann::json, FileError > read_json (const std::string &filepath)
 Read a json file from disk.
std::expected< bool, FileError > write_json (const std::string &filepath, const nlohmann::json &json)
 Write json to disk.
void open_url (const std::string &url) noexcept
 Open URL in default webbrowser.

Function Documentation

◆ extension()

std::expected< std::string, FileError > galaxy::fileutils::extension ( const std::string & filepath)
nodiscardnoexcept

Get a file or path's extension.

Parameters
filepathFilename or path with a filename.
Returns
Extension, including dot. Filerror if an unexpected error occured.

Definition at line 21 of file FileUtils.cpp.

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

◆ read()

std::expected< std::string, FileError > galaxy::fileutils::read ( const std::string & filepath)
nodiscard

Read a non-binary file on disk.

Parameters
filepathPath to file to read.
Returns
Data, or filerror if an unexpected error occured.

Definition at line 32 of file FileUtils.cpp.

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

◆ write()

std::expected< bool, FileError > galaxy::fileutils::write ( const std::string & filepath,
const std::string & data )
nodiscard

Writes a non-binary file to disk.

Parameters
filepathPath to file to write to.
dataData to write to file.
Returns
True on success, FileError on failure.

Definition at line 62 of file FileUtils.cpp.

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

◆ read_json()

std::expected< nlohmann::json, FileError > galaxy::fileutils::read_json ( const std::string & filepath)
nodiscard

Read a json file from disk.

Parameters
filepathPath to file to read.
Returns
Fully parsed json object. FileError if parsing failed.

Definition at line 89 of file FileUtils.cpp.

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

◆ write_json()

std::expected< bool, FileError > galaxy::fileutils::write_json ( const std::string & filepath,
const nlohmann::json & json )
nodiscard

Write json to disk.

Parameters
filepathPath to file to write to.
jsonJson data to write.
Returns
True on success. FileError if parsing failed.

Definition at line 100 of file FileUtils.cpp.

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

◆ open_url()

void galaxy::fileutils::open_url ( const std::string & url)
noexcept

Open URL in default webbrowser.

Parameters
urlURL to website to open.

Definition at line 111 of file FileUtils.cpp.

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