Compare commits

..

No commits in common. "e7711a3d59989126922ea80ed4719c8cef5c4529" and "ee9b5d4f673e2a144b17b292eed2b9aea525d7a2" have entirely different histories.

3 changed files with 4 additions and 10 deletions

2
.gitignore vendored
View File

@ -23,5 +23,3 @@
#vscode
.vscode
writeTest

View File

@ -26,11 +26,7 @@
File::File(std::string path, char mode, uint64_t cursorPosition): mode(mode), path(path), cursorPosition(cursorPosition){
std::filesystem::path filePath = path;
if(this->mode == 'w' || this->mode == 'a'){
this->size = ErrorOr<uint64_t>(0);
}else{
this->size = ErrorOr<uint64_t>(std::filesystem::file_size(filePath));
}
this->size = ErrorOr<uint64_t>(std::filesystem::file_size(filePath));
this->open();
}
@ -170,7 +166,7 @@ ErrorOrVoid File::writeString(tiny_utf8::string data){
}
ErrorOr<File*> File::open(std::string path, char mode, uint64_t startPosition){
if (!std::filesystem::exists(path) && (mode == 'r' || mode == 'm')) {
if (!std::filesystem::exists(path)) {
return ErrorOr<File*>(true, ErrorCodes::FILE_NOT_FOUND, nullptr);
}

View File

@ -48,11 +48,11 @@ int main(){
File *readFile;
//writeByte test
writeFile = File::open("resources/writeTest", 'w').value;
writeFile = File::open("resources/unicode_data/writeTest", 'w').value;
writeFile->writeByte('a');
writeFile->close();
readFile = File::open("resources/writeTest", 'r').value;
readFile = File::open("resources/unicode_data/writeTest", 'r').value;
uint8_t testByte = readFile->readByte().value;
ASSERT(testByte == 'a');
std::cout << "Passed write byte test." << std::endl;