diff --git a/src/lib/file.cpp b/src/lib/file.cpp index 0673acc..0c99d08 100644 --- a/src/lib/file.cpp +++ b/src/lib/file.cpp @@ -29,7 +29,6 @@ File::File(std::string path, char mode, uint64_t cursorPosition): mode(mode), pa this->size = ErrorOr(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 File::readByte(){ uint8_t* nextPointer = new uint8_t; uint8_t nextByte; diff --git a/src/lib/file.hpp b/src/lib/file.hpp index f274d0f..24214af 100644 --- a/src/lib/file.hpp +++ b/src/lib/file.hpp @@ -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 readByte();