Skip to content

Commit

Permalink
feat(cyber): check if file exist in file interface
Browse files Browse the repository at this point in the history
Change-Id: I8256fc11fe54f422b1804fdcf8bdcf3a03f5029d
  • Loading branch information
daohu527 committed Feb 2, 2023
1 parent 19cafde commit ea9d6a3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cyber/common/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ bool GetProtoFromBinaryFile(const std::string &file_name,

bool GetProtoFromFile(const std::string &file_name,
google::protobuf::Message *message) {
if (!PathExists(file_name)) {
AERROR << "File does not exist! " << file_name;
return false;
}
// Try the binary parser first if it's much likely a binary proto.
static const std::string kBinExt = ".bin";
if (std::equal(kBinExt.rbegin(), kBinExt.rend(), file_name.rbegin())) {
Expand Down

0 comments on commit ea9d6a3

Please sign in to comment.