Main Page
Namespaces
Classes
Package Documentation
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
{
23
std::ofstream
outputFile
;
24
outputFile.open(filename.c_str());
25
outputFile <<
content
;
26
outputFile.close();
27
}
28
29
bool
FileIO::readStringFromFile
(
std::string
const
&
filename
,
std::string
&
content
)
30
{
31
if
(!
fileExists
(filename))
32
return
false
;
33
34
std::ifstream
inputFile
(filename.c_str());
35
inputFile
.seekg(0,
std::ios::end
);
36
content.reserve(
inputFile
.tellg());
37
inputFile
.seekg(0, std::ios::beg);
38
content.assign((std::istreambuf_iterator<char>(
inputFile
)), std::istreambuf_iterator<char>());
39
inputFile
.close();
40
return
true
;
41
}
42
43
bool
FileIO::fileExists
(
std::string
const
&
path
)
44
{
45
std::ifstream
ifile
(path.c_str());
46
return
!
ifile
.fail();
47
}
48
callgraph.path
path
Definition:
callgraph.py:39
ws_sso_content_reader.content
content
Definition:
ws_sso_content_reader.py:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
corrVsCorr.filename
filename
Definition:
corrVsCorr.py:122
jsoncollector::FileIO::readStringFromFile
static bool readStringFromFile(std::string const &filename, std::string &content)
Definition:
FileIO.cc:29
FileIO.h
end
#define end
Definition:
vmac.h:39
analyzePatCleaning_cfg.inputFile
inputFile
Definition:
analyzePatCleaning_cfg.py:6
jsoncollector::FileIO::writeStringToFile
static void writeStringToFile(std::string const &filename, std::string &content)
Definition:
FileIO.cc:21
download_sqlite_cfg.outputFile
outputFile
Definition:
download_sqlite_cfg.py:5
jsoncollector::FileIO::fileExists
static bool fileExists(std::string const &path)
Definition:
FileIO.cc:43
compare_using_db.ifile
ifile
Definition:
compare_using_db.py:251
jsoncollector
Definition:
DataPoint.h:26
Generated for CMSSW Reference Manual by
1.8.11