third_party/libprocess/include/stout/protobuf.hpp
// A wrapper function that wraps the above read() with
// open and closing the file.
A wrapper function that wraps the above read() with
open and closing the file.
A wrapper function that wraps the above read () with open and closing the file .
inline Result<bool> read(const std::string& path,
                         google::protobuf::Message* message)
{
  Try<int> fd = os::open(path, O_RDONLY,
                         S_IRUSR | S_IWUSR | S_IRGRP | S_IRWXO);
  if (fd.isError()) {
    return Result<bool>::error("Failed to open file " + path);
  }
  Result<bool> result = read(fd.get(), message);
  os::close(fd.get());
  return result;
}
inline Result < bool > read ( const std :: string & path , google :: protobuf :: Message * message ) { Try < int > fd = os :: open ( path , O_RDONLY , S_IRUSR | S_IWUSR | S_IRGRP | S_IRWXO ) ; if ( fd . isError ( ) ) { return Result < bool > :: error ( " " + path ) ; } Result < bool > result = read ( fd . get ( ) , message ) ; os :: close ( fd . get ( ) ) ; return result ; }
A wrapper function that wraps the above read() with
open and closing the file.
A wrapper function that wraps the above read () with open and closing the file .
// NOTE: We ignore the return value of close(). This is because users calling // this function are interested in the return value of read(). Also an // unsuccessful close() doesn't affect the read.