Added colored text in terminal
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user