-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBloodlust.cpp
More file actions
83 lines (62 loc) · 1.6 KB
/
Copy pathBloodlust.cpp
File metadata and controls
83 lines (62 loc) · 1.6 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
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <pthread.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <iomanip>
#include "json.hpp"
using json = nlohmann::json;
using namespace std;
const int winWidth = 1280, winHeight = 720;
const char* osName = "Bloodlust";
// initializing
bool initSystemResources(int p_cores, int p_ram, int p_storage);
// Main Os Functions
bool initLayout();
bool startOS();
int main(int argc, char* argv[]) {
if (!initSystemResources(stoi(argv[1]), stoi(argv[2]), stoi(argv[3]))) {
cout << "System failure while initializing system resources!!!\n";
return 1;
}
if (!startOS()) {
cout << "Error starting Operating System!!!\n";
return 1;
}
return 0;
}
// initializing
bool initSystemResources(int p_cores, int p_ram, int p_storage) {
try {
std::ifstream i("SystemData.json");
json j;
i >> j;
j["Resources"]["Cores"] = p_cores;
j["Resources"]["Memory"] = p_ram;
j["Resources"]["Disk"] = p_storage;
std::ofstream o("SystemData.json");
o << std::setw(4) << j << std::endl;
}
catch (...) {
return false;
}
return true;
}
bool lockScreen() {
try {
const char* programPath = "/home/f223078/Documents/Project/MiniOS/Lockscreen";
system("./g++ -o Lockscreen Lockscreen.cpp -lraylib");
system(programPath);
}
catch(...) {
return false;
}
return true;
}
bool startOS() {
if (!lockScreen()) {
cout << "Error locking screen!!!\n";
return false;
}
return true;
}