CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FileUtils.cc
Go to the documentation of this file.
3 #include <fstream>
4 #include <sstream>
5 
31  std::ifstream inputFile;
32  inputFile.open (fileName.c_str());
33  if(!inputFile.good()){
34  std::stringstream msg;
35  msg << "File \"" << fileName << "\" cannot be open.";
36  inputFile.close();
37  throw cond::Exception(msg.str());
38  }
39  // get pointer to associated buffer object
40  std::filebuf* pbuf=inputFile.rdbuf();
41  // get file size using buffer's members
42  long size=pbuf->pubseekoff (0,std::ios::end,std::ios::in);
43  pbuf->pubseekpos (0,std::ios::in);
44  // allocate memory to contain file data
45  char* buffer=new char[size+1];
46  // get file data
47  pbuf->sgetn (buffer,size);
48  inputFile.close();
49  buffer[size]=0;
50  m_content += buffer;
51  delete [] buffer;
52  return true;
53 }
std::string m_content
Definition: FileUtils.h:21
bool read(const std::string &fileName)
Definition: FileUtils.cc:6
#define end
Definition: vmac.h:37
tuple size
Write out results.