lib/file.cpp:Fix exception warnings
parent
09503d3dc7
commit
c204aa7d76
|
@ -28,7 +28,7 @@ File::File(std::string path, char mode, uint64_t cursorPosition): mode(mode), pa
|
||||||
try{
|
try{
|
||||||
std::filesystem::path filePath = path;
|
std::filesystem::path filePath = path;
|
||||||
this->size = ErrorOr<uint64_t>(std::filesystem::file_size(filePath));
|
this->size = ErrorOr<uint64_t>(std::filesystem::file_size(filePath));
|
||||||
}catch(std::exception e){
|
}catch(std::exception& e){
|
||||||
this->size = ErrorOr<uint64_t>(true, ErrorCodes::FILE_NOT_FOUND);
|
this->size = ErrorOr<uint64_t>(true, ErrorCodes::FILE_NOT_FOUND);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ void File::open(){
|
||||||
try{
|
try{
|
||||||
std::filesystem::path filePath = this->path;
|
std::filesystem::path filePath = this->path;
|
||||||
this->size = ErrorOr<uint64_t>(std::filesystem::file_size(filePath));
|
this->size = ErrorOr<uint64_t>(std::filesystem::file_size(filePath));
|
||||||
}catch(std::exception e){
|
}catch(std::exception& e){
|
||||||
this->size = ErrorOr<uint64_t>(true, ErrorCodes::FILE_NOT_FOUND);
|
this->size = ErrorOr<uint64_t>(true, ErrorCodes::FILE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ ErrorOr<uint8_t> File::readByte(){
|
||||||
try{
|
try{
|
||||||
this->fileStream.read(byte, 1);
|
this->fileStream.read(byte, 1);
|
||||||
delete byte;
|
delete byte;
|
||||||
}catch(std::exception e){
|
}catch(std::exception& e){
|
||||||
return ErrorOr<uint8_t>(true, ErrorCodes::FILE_READ_FAILED);
|
return ErrorOr<uint8_t>(true, ErrorCodes::FILE_READ_FAILED);
|
||||||
}
|
}
|
||||||
return ErrorOr<uint8_t>((uint8_t) *byte);
|
return ErrorOr<uint8_t>((uint8_t) *byte);
|
||||||
|
@ -136,7 +136,7 @@ ErrorOr<std::vector<uint8_t>> File::read(uint64_t bytes){
|
||||||
data.push_back((uint8_t) buffer[i]);
|
data.push_back((uint8_t) buffer[i]);
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}catch(std::exception e){
|
}catch(std::exception& e){
|
||||||
return ErrorOr<std::vector<uint8_t>>(true, ErrorCodes::FILE_READ_FAILED);
|
return ErrorOr<std::vector<uint8_t>>(true, ErrorCodes::FILE_READ_FAILED);
|
||||||
}
|
}
|
||||||
return ErrorOr<std::vector<uint8_t>>(data);
|
return ErrorOr<std::vector<uint8_t>>(data);
|
||||||
|
|
Loading…
Reference in New Issue