CMS 3D CMS Logo

List of all members | Static Public Member Functions
jsoncollector::FileIO Class Reference

#include <FileIO.h>

Static Public Member Functions

static bool fileExists (std::string const &path)
 
static bool readStringFromFile (std::string const &filename, std::string &content)
 
static void writeStringToFile (std::string const &filename, std::string &content)
 

Detailed Description

Definition at line 15 of file FileIO.h.

Member Function Documentation

◆ fileExists()

bool FileIO::fileExists ( std::string const &  path)
static

Checks if path points to an existing file

Definition at line 41 of file FileIO.cc.

41  {
42  std::ifstream ifile(path.c_str());
43  return !ifile.fail();
44 }

References compare_using_db::ifile, and castor_dqm_sourceclient_file_cfg::path.

Referenced by readStringFromFile().

◆ readStringFromFile()

bool FileIO::readStringFromFile ( std::string const &  filename,
std::string &  content 
)
static

Reads string from specified path, returns false if file does not exist

Definition at line 28 of file FileIO.cc.

28  {
29  if (!fileExists(filename))
30  return false;
31 
32  std::ifstream inputFile(filename.c_str());
33  inputFile.seekg(0, std::ios::end);
34  content.reserve(inputFile.tellg());
35  inputFile.seekg(0, std::ios::beg);
36  content.assign((std::istreambuf_iterator<char>(inputFile)), std::istreambuf_iterator<char>());
37  inputFile.close();
38  return true;
39 }

References Skims_PA_cff::content, mps_fire::end, fileExists(), corrVsCorr::filename, and dtResolutionTest_cfi::inputFile.

Referenced by jsoncollector::DataPointDefinition::getDataPointDefinitionFor().

◆ writeStringToFile()

void FileIO::writeStringToFile ( std::string const &  filename,
std::string &  content 
)
static
jsoncollector::FileIO::fileExists
static bool fileExists(std::string const &path)
Definition: FileIO.cc:41
download_sqlite_cfg.outputFile
outputFile
Definition: download_sqlite_cfg.py:5
compare_using_db.ifile
ifile
Definition: compare_using_db.py:251
mps_fire.end
end
Definition: mps_fire.py:242
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
Skims_PA_cff.content
content
Definition: Skims_PA_cff.py:19
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37