PhoenixFileParser
1.7.3
Set of tools to ease file parsing
Toggle main menu visibility
Loading...
Searching...
No Matches
openFileStream.cpp
Go to the documentation of this file.
1
2
/***************************************
3
Auteur : Pierre Aubert
4
Mail : pierre.aubert@lapp.in2p3.fr
5
Licence : CeCILL-C
6
****************************************/
7
8
#include <iostream>
9
#include "convertToString.h"
10
#include "
openFileStream.h
"
11
12
14
18
bool
openFileStream
(std::ofstream & fs,
const
PPath & fileName){
19
fs.open(fileName.c_str());
20
if
(!fs.is_open()){
21
std::cerr <<
"openFileStream : can't open file '"
<< fileName <<
"'"
<< std::endl;
22
return
false
;
23
}
else
return
true
;
24
}
25
27
31
bool
openFileStream
(std::ifstream & fs,
const
PPath & fileName){
32
fs.open(fileName.c_str());
33
if
(!fs.is_open()){
34
std::cerr <<
"openFileStream : can't open file '"
<< fileName <<
"'"
<< std::endl;
35
return
false
;
36
}
else
return
true
;
37
}
38
40
45
bool
openFileStream
(
PVecOFStream
& fs,
const
PPath & fileName,
size_t
nbFile){
46
if
(nbFile == 0lu){
return
true
;}
//There is no problem in oppening 0 file
47
PPath baseFileName(fileName.eraseExtension()), extention(fileName.getExtension());
48
if
(extention !=
""
){extention = PString(
"."
+ extention);}
49
fs.resize(nbFile);
50
bool
b(
true
);
51
size_t
i(0lu);
52
for
(PVecOFStream::iterator it(fs.begin()); it != fs.end(); ++it){
53
PPath tmpFileName(baseFileName + PPath(
"_"
) + valueToString(i) + extention);
54
b &=
openFileStream
(*it, tmpFileName);
55
++i;
56
}
57
return
b;
58
}
59
61
66
bool
openFileStream
(
PVecIFStream
& fs,
const
PPath & fileName,
size_t
nbFile){
67
if
(nbFile == 0lu){
return
true
;}
//There is no problem in oppening 0 file
68
PPath baseFileName(fileName.eraseExtension()), extention(fileName.getExtension());
69
if
(extention !=
""
){extention = PPath(
"."
+ extention);}
70
fs.resize(nbFile);
71
bool
b(
true
);
72
size_t
i(0lu);
73
for
(PVecIFStream::iterator it(fs.begin()); it != fs.end(); ++it){
74
PPath tmpFileName(baseFileName + PPath(
"_"
) + valueToString(i) + extention);
75
b &=
openFileStream
(*it, tmpFileName);
76
++i;
77
}
78
return
b;
79
}
80
82
84
void
closeFileStream
(
PVecOFStream
& fs){
85
for
(PVecOFStream::iterator it(fs.begin()); it != fs.end(); ++it){
86
it->close();
87
}
88
}
89
91
93
void
closeFileStream
(
PVecIFStream
& fs){
94
for
(PVecIFStream::iterator it(fs.begin()); it != fs.end(); ++it){
95
it->close();
96
}
97
}
98
openFileStream
bool openFileStream(std::ofstream &fs, const PPath &fileName)
Open a ofstream and says if there is a problem.
Definition
openFileStream.cpp:18
closeFileStream
void closeFileStream(PVecOFStream &fs)
Close a vector of ofstream.
Definition
openFileStream.cpp:84
openFileStream.h
PVecIFStream
std::vector< std::ifstream > PVecIFStream
Definition
openFileStream.h:16
PVecOFStream
std::vector< std::ofstream > PVecOFStream
Definition
openFileStream.h:15
src
openFileStream.cpp
Generated by
1.17.0