-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (61 loc) · 1.57 KB
/
main.cpp
File metadata and controls
70 lines (61 loc) · 1.57 KB
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
#include <fstream>
#include "OperationsGraph.cpp"
#include <direct.h> // _getcwd
string getCurrentWorkingDirectory()
{
#ifdef _WIN32
char buffer[FILENAME_MAX];
_getcwd(buffer, FILENAME_MAX);
return string(buffer);
#else
char buffer[FILENAME_MAX];
getcwd(buffer, FILENAME_MAX);
return string(buffer);
#endif
}
int main()
{
OperationsGraph graph;
// dva moguca nacina za input programa za obfuskaciju
cout << "1 FOR CONSOLE / 2 FOR FILE INPUT: ";
int choice;
cin >> choice;
cin.ignore();
if (choice == 1)
{
cout << "Enter operations (empty line to finish):\n";
processInput(cin, graph);
}
else if (choice == 2)
{
string filename;
cout << "Enter the filename (with .txt): ";
getline(cin, filename);
string currentPath = getCurrentWorkingDirectory();
// izaci iz output foldera i uci u test-files
string filePath = currentPath.substr(0, currentPath.find_last_of("\\/")) + "/test-files/" + filename;
ifstream file(filePath);
if (!file.is_open())
{
cout << "Error opening the file: " << filePath << endl;
return 1; // error
}
cout << "\nReading file contents from: " << filePath << endl;
processInput(file, graph);
file.close();
}
else
{
cout << "Invalid choice. Exiting." << endl;
return 1; // error
}
try
{
graph.obfuscate();
}
catch (const runtime_error &e)
{
cout << "Error: " << e.what() << endl;
}
return 0;
}