lib/file: change File::eof to a function
This is just way easier to implement and less messy.Soda
parent
8bb633f118
commit
5059bd0193
|
@ -29,7 +29,6 @@ File::File(std::string path, char mode, uint64_t cursorPosition): mode(mode), pa
|
|||
this->size = ErrorOr<uint64_t>(std::filesystem::file_size(filePath));
|
||||
this->open();
|
||||
this->isOpen = true;
|
||||
this->eof = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,6 +56,10 @@ void File::close(){
|
|||
this->isOpen = false;
|
||||
}
|
||||
|
||||
bool File::eof() {
|
||||
return !this->size.isError && this->cursorPosition >= this->size.value;
|
||||
}
|
||||
|
||||
ErrorOr<uint8_t> File::readByte(){
|
||||
uint8_t* nextPointer = new uint8_t;
|
||||
uint8_t nextByte;
|
||||
|
|
|
@ -39,7 +39,6 @@ class File {
|
|||
File(std::string path, char mode, uint64_t cursorPosition);
|
||||
public:
|
||||
bool isOpen;
|
||||
bool eof;
|
||||
std::string path;
|
||||
uint64_t cursorPosition;
|
||||
// may be error if not a regular file or size cannot be determined
|
||||
|
@ -49,6 +48,8 @@ class File {
|
|||
void open();
|
||||
void close();
|
||||
|
||||
bool eof();
|
||||
|
||||
// only applicable to read and edit modes
|
||||
// moves the cursor to the right of the read section
|
||||
ErrorOr<uint8_t> readByte();
|
||||
|
|
Loading…
Reference in New Issue