front and backend can now communicate

This commit is contained in:
jakani24
2024-03-17 20:15:58 +01:00
parent 7ea487d0e1
commit 9daeaff131
33 changed files with 1301 additions and 148 deletions

View File

@@ -5,30 +5,41 @@
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <iomanip>
int check_for_com_tasks(const std::string& com_name, const std::string& com_path) {
std::ifstream file(com_path);
if (!file.is_open()) {
// No com file found = no communication needed
return 1;
return 1; // Error opening file
}
std::string command;
while (file >> command) {
// Scan the command
std::string path;
file >> path; // Scan the path
// Add command and path to the queue
std::string queue_entry = command + ";" + path;
queue_push(queue_entry.c_str());
std::string path;
std::string line;
while (std::getline(file, line)) {
std::stringstream ss(line);
if (ss >> command) {
// Check if the next token is a quoted path
if (line.find("\"") != std::string::npos) {
size_t start = line.find("\"") + 1; // Start after the opening quote
size_t end = line.find_last_of("\""); // Find the last quote
if (start != std::string::npos && end != std::string::npos) {
path = line.substr(start, end - start);
}
}
else {
// If no quotes found, simply take the next token as the path
ss >> path;
}
// Add command and path to the queue
std::string queue_entry = command + ";" + path;
queue_push(queue_entry.c_str());
}
}
// Remove the com file after processing
file.close();
std::remove(com_path.c_str());
return 0;
}
#endif // !LOCAL_COM_CPP