src
EventFilter
Utilities
src
FileIO.cc
Go to the documentation of this file.
1
/*
2
* FileIO.cc
3
*
4
* Created on: Sep 25, 2012
5
* Author: aspataru
6
*/
7
8
#include "
EventFilter/Utilities/interface/FileIO.h
"
9
10
#include <iostream>
11
#include <fstream>
12
#include <streambuf>
13
#include <cstdlib>
14
#include <dirent.h>
15
#include <cstdio>
16
#include <sys/stat.h>
17
#include <cstring>
18
19
using namespace
jsoncollector
;
20
21
void
FileIO::writeStringToFile
(
std::string
const
&
filename
,
std::string
&
content
) {
22
std::ofstream
outputFile
;
23
outputFile
.open(
filename
.c_str());
24
outputFile
<<
content
;
25
outputFile
.close();
26
}
27
28
bool
FileIO::readStringFromFile
(
std::string
const
&
filename
,
std::string
&
content
) {
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
}
40
41
bool
FileIO::fileExists
(
std::string
const
&
path
) {
42
std::ifstream
ifile
(
path
.c_str());
43
return
!
ifile
.fail();
44
}
castor_dqm_sourceclient_file_cfg.path
path
Definition:
castor_dqm_sourceclient_file_cfg.py:37
corrVsCorr.filename
filename
Definition:
corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
jsoncollector::FileIO::readStringFromFile
static bool readStringFromFile(std::string const &filename, std::string &content)
Definition:
FileIO.cc:28
FileIO.h
jsoncollector::FileIO::writeStringToFile
static void writeStringToFile(std::string const &filename, std::string &content)
Definition:
FileIO.cc:21
mps_fire.end
end
Definition:
mps_fire.py:242
download_sqlite_cfg.outputFile
outputFile
Definition:
download_sqlite_cfg.py:5
Skims_PA_cff.content
content
Definition:
Skims_PA_cff.py:19
jsoncollector::FileIO::fileExists
static bool fileExists(std::string const &path)
Definition:
FileIO.cc:41
compare_using_db.ifile
ifile
Definition:
compare_using_db.py:251
jsoncollector
JSON (JavaScript Object Notation).
Definition:
DataPoint.h:26
makeListRunsInFiles.inputFile
inputFile
Definition:
makeListRunsInFiles.py:112
Generated for CMSSW Reference Manual by
1.8.14