Added colored text in terminal

This commit is contained in:
Pasha Bibko
2025-07-20 13:10:57 +01:00
parent c8975f0c20
commit 7768ba4522
4 changed files with 95 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ namespace LXC::Util
{
struct FileReadError
{
// Different reasons why the error can occur //
enum Reason
{
FileNotFound,
@@ -14,12 +15,27 @@ namespace LXC::Util
NotAFile
};
// Constructor to pass arguments to the struct //
FileReadError(const std::filesystem::path& _path, Reason _reason)
: path(_path), reason(_reason)
{}
std::filesystem::path path;
Reason reason;
// Error information //
const std::filesystem::path path;
const Reason reason;
// Turns the error into a c-string //
inline static const char* const ReasonStr(const Reason& reason)
{
static const char* reasons[] =
{
"File cannot be found",
"File reading permissions are denied",
"Not a file"
};
return reasons[reason];
}
};
inline ReturnVal<std::string, FileReadError> ReadFile(const std::filesystem::path& filepath)