PhoenixClockMock  1.0.0
Tool to manipulate mock of clock
Loading...
Searching...
No Matches
main_restore.cpp File Reference
#include "OptionParser.h"
#include "phoenix_clock_mock.h"
+ Include dependency graph for main_restore.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program.
 
int main (int argc, char **argv)
 
bool restoreAllMock (const std::vector< PPath > &vecInputFile)
 Restore all mock files.
 
bool restoreMockFile (const PPath &inputFile)
 Restore a mock file.
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 14 of file main_restore.cpp.

14 {
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}

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 54 of file main_restore.cpp.

54 {
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}
bool restoreAllMock(const std::vector< PPath > &vecInputFile)
Restore all mock files.
OptionParser createOptionParser()
Create the OptionParser of this program.

References createOptionParser(), and restoreAllMock().

+ Here is the call graph for this function:

◆ restoreAllMock()

bool restoreAllMock ( const std::vector< PPath > & vecInputFile)

Restore all mock files.

Parameters
vecInputFile: vector of input files to restore
Returns
true on success, false otherwise

Definition at line 46 of file main_restore.cpp.

46 {
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}
bool restoreMockFile(const PPath &inputFile)
Restore a mock file.

References restoreMockFile().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restoreMockFile()

bool restoreMockFile ( const PPath & inputFile)

Restore a mock file.

Parameters
inputFile: input file to be restored
Returns
true on success, false otherwise

Definition at line 27 of file main_restore.cpp.

27 {
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}

Referenced by restoreAllMock().

+ Here is the caller graph for this function: