Add checks to Data::LoadFromFile() and Data::StoreToFile()
This commit is contained in:
parent
e85019e95b
commit
7348f7c64d
@ -15,7 +15,11 @@ boost::optional<Data> Data::LoadFromFile(const bf::path &filepath) {
|
||||
if (!file.good()) {
|
||||
return boost::none;
|
||||
}
|
||||
return LoadFromStream(file);
|
||||
auto result = LoadFromStream(file);
|
||||
if (!file.good()) {
|
||||
throw std::runtime_error("Error reading from file");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::streampos Data::_getStreamSize(istream &stream) {
|
||||
|
@ -124,6 +124,9 @@ inline void Data::StoreToFile(const boost::filesystem::path &filepath) const {
|
||||
throw std::runtime_error("Could not open file for writing");
|
||||
}
|
||||
StoreToStream(file);
|
||||
if (!file.good()) {
|
||||
throw std::runtime_error("Error writing to file");
|
||||
}
|
||||
}
|
||||
|
||||
inline void Data::StoreToStream(std::ostream &stream) const {
|
||||
|
Loading…
Reference in New Issue
Block a user