First pass VN

This commit is contained in:
2023-02-08 20:44:18 -08:00
parent b0e64420df
commit 399180c2ca
3 changed files with 27 additions and 48 deletions

View File

@@ -22,13 +22,17 @@ bool_t File::open(enum FileMode mode) {
if(this->file == NULL) return false;
fseek(this->file, 0, SEEK_END);
this->length = ftell(this->file);
fseek(this->file, 0, SEEK_SET);
if(mode == FILE_MODE_READ) {
fseek(this->file, 0, SEEK_END);
this->length = ftell(this->file);
fseek(this->file, 0, SEEK_SET);
if(this->length <= 0) {
this->close();
return false;
if(this->length <= 0) {
this->close();
return false;
}
} else {
this->length = 0;
}
return true;
@@ -80,7 +84,7 @@ bool_t File::writeString(std::string in) {
const char_t *strOut = in.c_str();
// TODO: Validate write length.
fwrite(strOut, sizeof(char_t), in.size(), this->file);
this->length = fwrite(strOut, sizeof(char_t), in.size(), this->file);
return true;
}