Pasha Bibko Util Library
Loading...
Searching...
No Matches
FileRead.h
1#pragma once
2
3#include <classes/ReturnVal.h>
4
5#include <filesystem>
6
15namespace PashaBibko::Util
16{
24 {
34
39 FileReadError(const std::filesystem::path& _path, Reason _reason);
40
44 const std::filesystem::path path;
45
50
54 static const char* const ReasonStr(Reason reason);
55 };
56
65 ReturnVal<std::string, FileReadError> ReadFile(const std::filesystem::path& path);
66
74 {
75 unsigned short colummn;
76 unsigned short line;
77 };
78
88 StringLocation GetLocationAtStringIndex(const std::string& string, uint32_t index);
89}
Definition Colour.h:10
ReturnVal< std::string, FileReadError > ReadFile(const std::filesystem::path &path)
Reads a file to a string.
StringLocation GetLocationAtStringIndex(const std::string &string, uint32_t index)
Finds the location of [colummn, line] of a given index.
Error returned when PashaBibko::Util::ReadFile() fails.
Definition FileRead.h:24
const Reason reason
Why the file read failed.
Definition FileRead.h:49
FileReadError(const std::filesystem::path &_path, Reason _reason)
const std::filesystem::path path
Absolute file path of the error.
Definition FileRead.h:44
static const char *const ReasonStr(Reason reason)
Converts a FileReadError::Reason into a relevant c-string.
Reason
Different reasons why the error can occur.
Definition FileRead.h:29
@ FileNotFound
The file path did not point a file location.
Definition FileRead.h:30
@ PermissionDenied
The executable does not have the permissions to read the file.
Definition FileRead.h:31
@ NotAFile
The file path pointed to a folder not a file.
Definition FileRead.h:32
Location within a string.
Definition FileRead.h:74
unsigned short line
Definition FileRead.h:76
unsigned short colummn
Definition FileRead.h:75
Mathmatical vector class.
Definition Vec.h:216