From b81928d0b25a3de67d48858f574d118f175b8958 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Tue, 14 Jun 2022 22:20:07 +0200 Subject: [PATCH] Small fix --- src/component/io.cpp | 33 +++++---------------------------- src/component/io.hpp | 2 +- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/component/io.cpp b/src/component/io.cpp index e8e061f..f6649ae 100644 --- a/src/component/io.cpp +++ b/src/component/io.cpp @@ -33,17 +33,18 @@ namespace io scripting::script_value http_get(const gsc::function_args& args) { const auto url = args[0].as(); - const auto object = scripting::entity(scripting::make_object()); + const scripting::object object{}; + const auto object_id = object.get_entity_id(); - scheduler::once([object, url]() + scheduler::once([object_id, url]() { const auto result = utils::http::get_data(url.data()); - scheduler::once([object, result]() + scheduler::once([object_id, result]() { const auto value = result.has_value() ? result.value().substr(0, 0x5000) : ""; - scripting::notify(object, "done", {value}); + scripting::notify(object_id, "done", {value}); }); }, scheduler::pipeline::async); @@ -51,30 +52,6 @@ namespace io } } - std::string execute_command(const std::string& cmd) - { - const auto handle = _popen(cmd.data(), "r"); - char* buffer = (char*)calloc(256, sizeof(char)); - std::string result; - - if (!handle) - { - return ""; - } - - while (!feof(handle)) - { - if (fgets(buffer, 256, handle)) - { - result += buffer; - } - } - - _pclose(handle); - - return result; - } - class component final : public component_interface { public: diff --git a/src/component/io.hpp b/src/component/io.hpp index 8bc4861..cf90d51 100644 --- a/src/component/io.hpp +++ b/src/component/io.hpp @@ -2,5 +2,5 @@ namespace io { - std::string execute_command(const std::string& cmd); + } \ No newline at end of file