inst_util.cc
// Open a file and write the contents of an ASCII string into it.
// return "" on error.
Open a file and write the contents of an ASCII string into it.
return "" on error.
Open a file and write the contents of an ASCII string into it . return " " on error .
bool WriteStringToFile(const string& contents, const string& path) {
  int fd = open(path.c_str(),
                O_WRONLY  | O_CREAT | O_TRUNC,
                S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  if (fd == -1) {
    printf("WriteFileToString failed to open %s\n", path.c_str());
    return false;
  }
  bool success = (write(fd, contents.c_str(), contents.size()) ==
                  (int)contents.size());
  if (close(fd) != 0)
    return false;
  return success;
}
bool WriteStringToFile ( const string & contents , const string & path ) { int fd = open ( path . c_str ( ) , O_WRONLY | O_CREAT | O_TRUNC , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ) ; if ( fd == -1 ) { printf ( " \n " , path . c_str ( ) ) ; return false ; } bool success = ( write ( fd , contents . c_str ( ) , contents . size ( ) ) == ( int ) contents . size ( ) ) ; if ( close ( fd ) != 0 ) return false ; return success ; }
Open a file and write the contents of an ASCII string into it.
Open a file and write the contents of an ASCII string into it .