-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
47 lines (39 loc) · 1.62 KB
/
main.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
#include <iostream>
#include <filesystem>
#include "./src/app/processes/ProcessManagement.hpp"
#include "./src/app/processes/Task.hpp"
namespace fs = std::filesystem;
//check
int main(int argc, char* argv[]) {
std::string directory;
std::string action;
std::cout << "Enter the directory path: ";
std::getline(std::cin, directory);
std::cout << "Enter the action (encrypt/decrypt): ";
std::getline(std::cin, action);
try {
if (fs::exists(directory) && fs::is_directory(directory)) {
ProcessManagement processManagement;
for (const auto& entry : fs::recursive_directory_iterator(directory)) {
if (entry.is_regular_file()) {
std::string filePath = entry.path().string();
IO io(filePath);
std::fstream f_stream = std::move(io.getFileStream());
if (f_stream.is_open()) {
Action taskAction = (action == "encrypt") ? Action::ENCRYPT : Action::DECRYPT;
auto task = std::make_unique<Task>(std::move(f_stream), taskAction, filePath);
processManagement.submitToQueue(std::move(task));
} else {
std::cout << "Unable to open file: " << filePath << std::endl;
}
}
}
processManagement.executeTasks();
} else {
std::cout << "Invalid directory path!" << std::endl;
}
} catch (const fs::filesystem_error& ex) {
std::cout << "Filesystem error: " << ex.what() << std::endl;
}
return 0;
}