PhoenixClockMock
2.1.0
PhoenixClock mock files utilities
Toggle main menu visibility
Loading...
Searching...
No Matches
main_restore.cpp
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : LGPL-3.0-only
5
****************************************/
6
7
#include "OptionParser.h"
8
9
#include "
phoenix_clock_mock.h
"
10
12
14
OptionParser
createOptionParser
(){
15
OptionParser parser(
true
, __PROGRAM_VERSION__);
16
parser.setExampleLongOption(
"phoenix_clock_mock_restore --input=file.clockmock"
);
17
parser.setExampleShortOption(
"phoenix_clock_mock_restore -i file2.mock file2.clockmock"
);
18
19
parser.addOption(
"input"
,
"i"
, OptionType::FILENAME,
true
,
"List of input clock mock to be restored"
);
20
return
parser;
21
}
22
24
27
bool
restoreMockFile
(
const
PPath & inputFile){
28
size_t
fileSize(inputFile.getFileSize());
29
size_t
nbClockTime = ((fileSize -
sizeof
(size_t))*(fileSize >=
sizeof
(size_t) ))/
sizeof
(
size_t
);
30
FILE* fp = fopen(inputFile.c_str(),
"r+"
);
31
if
(fp == NULL){
32
std::cerr <<
"restoreMockFile : cannot open file '"
<<inputFile<<
"'"
<< std::endl;
33
return
false
;
34
}
35
fseek(fp, 0l, SEEK_SET);
36
bool
b = data_save(fp, nbClockTime);
37
fseek(fp, 0l, SEEK_END);
38
fclose(fp);
39
return
b;
40
}
41
43
46
bool
restoreAllMock
(
const
std::vector<PPath> & vecInputFile){
47
bool
b(
true
);
48
for
(std::vector<PPath>::const_iterator itFile(vecInputFile.begin()); itFile != vecInputFile.end(); ++itFile){
49
b &=
restoreMockFile
(*itFile);
50
}
51
return
b;
52
}
53
54
int
main
(
int
argc,
char
** argv){
55
OptionParser parser =
createOptionParser
();
56
parser.parseArgument(argc, argv);
57
const
OptionMode & defaultMode = parser.getDefaultMode();
58
std::vector<PPath> vecInputFile;
59
defaultMode.getValue(vecInputFile,
"input"
);
60
return
restoreAllMock
(vecInputFile) - 1;
61
}
62
63
main
int main(int argc, char **argv)
Definition
main_restore.cpp:54
restoreAllMock
bool restoreAllMock(const std::vector< PPath > &vecInputFile)
Restore all mock files.
Definition
main_restore.cpp:46
createOptionParser
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition
main_restore.cpp:14
restoreMockFile
bool restoreMockFile(const PPath &inputFile)
Restore a mock file.
Definition
main_restore.cpp:27
phoenix_clock_mock.h
program
main_restore.cpp
Generated by
1.17.0