third_party/libprocess/include/stout/protobuf.hpp
// A wrapper function that wraps the above write() with
// open and closing the file.
A wrapper function that wraps the above write() with
open and closing the file.
A wrapper function that wraps the above write () with open and closing the file .
inline Try<bool> write(const std::string& path,
                       const google::protobuf::Message& message)
{
  Try<int> fd = os::open(path, O_WRONLY | O_CREAT | O_TRUNC,
                         S_IRUSR | S_IWUSR | S_IRGRP | S_IRWXO);
  if (fd.isError()) {
    return Try<bool>::error("Failed to open file " + path);
  }
  Try<bool> result = write(fd.get(), message);
  os::close(fd.get());
  return result;
}
inline Try < bool > write ( const std :: string & path , const google :: protobuf :: Message & message ) { Try < int > fd = os :: open ( path , O_WRONLY | O_CREAT | O_TRUNC , S_IRUSR | S_IWUSR | S_IRGRP | S_IRWXO ) ; if ( fd . isError ( ) ) { return Try < bool > :: error ( " " + path ) ; } Try < bool > result = write ( fd . get ( ) , message ) ; os :: close ( fd . get ( ) ) ; return result ; }
A wrapper function that wraps the above write() with
open and closing the file.
A wrapper function that wraps the above write () 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 write(). Also an // unsuccessful close() doesn't affect the write.