RAVENNAKIT
Loading...
Searching...
No Matches
rav::file Namespace Reference

Enumerations

enum class  Error {
  invalid_path , file_does_not_exist , failed_to_open , failed_to_get_file_size ,
  failed_to_read_from_file
}

Functions

bool create_if_not_exists (const std::filesystem::path &path)
 Creates the file if it does not already exist.
tl::expected< std::string, Error > read_file_as_string (const std::filesystem::path &file)
 Reads the contents of given file into a string.

Enumeration Type Documentation

◆ Error

enum class rav::file::Error
strong
Enumerator
invalid_path 
file_does_not_exist 
failed_to_open 
failed_to_get_file_size 
failed_to_read_from_file 

Definition at line 34 of file file.hpp.

Function Documentation

◆ create_if_not_exists()

bool rav::file::create_if_not_exists ( const std::filesystem::path & path)
inlinenodiscard

Creates the file if it does not already exist.

Returns
True if the file was created or already existed, or false if the file could not be created.

Definition at line 46 of file file.hpp.

◆ read_file_as_string()

tl::expected< std::string, Error > rav::file::read_file_as_string ( const std::filesystem::path & file)
inline

Reads the contents of given file into a string.

Parameters
fileThe file to read from.
Returns
An expected holding a string with the contents on success, or an Error in case of failure.

Definition at line 65 of file file.hpp.