Check ifstream::good() in proto_stream.cc (#929)

Check for basic stream errors before doing more involved read actions.
The log message in this case is also more descriptive than
`Check failed: reader->ReadProto(&pose_graph)`.
master
Michael Grupp 2018-02-22 16:21:15 +01:00 committed by Wally B. Feed
parent 94fce13f62
commit 90994464a5
1 changed files with 2 additions and 0 deletions

View File

@ -15,6 +15,7 @@
*/
#include "cartographer/io/proto_stream.h"
#include "glog/logging.h"
namespace cartographer {
namespace io {
@ -71,6 +72,7 @@ ProtoStreamReader::ProtoStreamReader(const std::string& filename)
if (!ReadSizeAsLittleEndian(&in_, &magic) || magic != kMagic) {
in_.setstate(std::ios::failbit);
}
CHECK(in_.good()) << "Failed to open proto stream '" << filename << "'.";
}
bool ProtoStreamReader::Read(std::string* decompressed_data) {