/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
CondCore/CondDB/src/FileUtils.cc
29 строк
893 B
Cms Build
Clang-Format
29 май 2019, 08:23
29 май 2019, 08:23
087900c
Код
Авторство
О чём код?
#include "CondCore/CondDB/interface/FileUtils.h" #include "CondCore/CondDB/interface/Exception.h" #include <fstream> #include <sstream> bool cond::FileReader::read(const std::string& fileName) { std::ifstream inputFile; inputFile.open(fileName.c_str()); if (!inputFile.good()) { std::stringstream msg; msg << "File \"" << fileName << "\" cannot be open."; inputFile.close(); throw cond::Exception(msg.str()); } // get pointer to associated buffer object std::filebuf* pbuf = inputFile.rdbuf(); // get file size using buffer's members long size = pbuf->pubseekoff(0, std::ios::end, std::ios::in); pbuf->pubseekpos(0, std::ios::in); // allocate memory to contain file data char* buffer = new char[size + 1]; // get file data pbuf->sgetn(buffer, size); inputFile.close(); buffer[size] = 0; m_content += buffer; delete[] buffer; return true; }