try using pipe

This commit is contained in:
jakani24
2024-03-19 21:14:48 +01:00
parent 9daeaff131
commit fd20338513
43 changed files with 675 additions and 250 deletions

View File

@@ -1,15 +1,16 @@
#ifndef LOCAL_COM_CPP
#define LOCAL_COM_CPP
#include "local_com.h"
#include "connect.h"
#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);
/*std::ifstream file(com_path);
if (!file.is_open()) {
return 1; // Error opening file
}
@@ -40,6 +41,21 @@ int check_for_com_tasks(const std::string& com_name, const std::string& com_path
file.close();
std::remove(com_path.c_str());
*/
std::string line;
std::string command="";
std::string path="";
line=read_from_pipe();
std::stringstream ss(line);
if (ss >> command) {
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);
}
}
std::string queue_entry = command + ";" + path;
queue_push(queue_entry.c_str());
return 0;
}
#endif // !LOCAL_COM_CPP