-
Notifications
You must be signed in to change notification settings - Fork 1
/
Helper.cpp
79 lines (59 loc) · 1.8 KB
/
Helper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//Configuration.cpp
#include <iostream>
#include <fstream>
#include "Helper.h"
#include "Configuration.h"
#include "string.h"
#include <cstdio>
#include <ctime>
#include <vector>
#include <iterator>
#include <unistd.h>
using namespace std;
void Helper::Init()
{
start = clock();
}
void Helper::GetFileContent(string fileName, vector<string> &vecOfStrs)
{
// Open the File
ifstream in(fileName.c_str());
// Check if object is valid
if(!in)
{
//cerr << "Cannot open the File : "<<fileName<<endl;
}
else {
string str;
// Read the next line from File untill it reaches the end.
while (std::getline(in, str))
{
// Line contains string of length > 0 then save it in vector
if(str.size() > 0)
vecOfStrs.push_back(str);
}
//Close The File
in.close();
}
}
void Helper::WriteVectorToFile(string fileName, const vector<string> &message)
{
std::ofstream output_file(fileName);
std::ostream_iterator<std::string> output_iterator(output_file, "\n");
std::copy(message.begin(), message.end(), output_iterator);
}
void Helper::WriteTextToLogFile(const string &message)
{
if(_cfg.logging == 1) {
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
ofstream myfile;
myfile.open ("logging.txt", ios_base::app);
myfile << message << " ?? Duraction " << duration << ";" << "\n";
myfile.close();
}
}
void Helper::executeCommand (string emulatorPath, string emulatorName, string emulatorParams, string fileToBeExecuted, string emulatorType, string posX, string posY) {
cout << "start inv cov:" << posX << " " << posY << endl;
execlp("./invoker.elf","invoker.elf", emulatorPath.c_str(), emulatorName.c_str(), emulatorParams.c_str(), fileToBeExecuted.c_str(), emulatorType.c_str(), posX.c_str(), posY.c_str(), NULL);
cout << "done inv cov" << endl;
}