aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2024-06-06 11:03:51 +0100
committerGitHub <noreply@github.com>2024-06-06 11:03:51 +0100
commita73741d3b7060a0a484764bb34a7fb12ddf2e40d (patch)
tree2077f68eb094cea102ac712d2e75a5448dc639c6 /src/main.cpp
parentfb2849e02e63b9344ae880fb3e1edff8126dc8ca (diff)
parent08382cb05dc23816f36c0a52b23c4d501431f88c (diff)
Merge pull request #3690 from laytan/orcas
Runtime support for orca
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3ca024ed9..70def5802 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -155,6 +155,38 @@ gb_internal i32 system_exec_command_line_app(char const *name, char const *fmt,
return exit_code;
}
+#if defined(GB_SYSTEM_WINDOWS)
+#define popen _popen
+#define pclose _pclose
+#endif
+
+gb_internal bool system_exec_command_line_app_output(char const *command, gbString *output) {
+ GB_ASSERT(output);
+
+ u8 buffer[256];
+ FILE *stream;
+ stream = popen(command, "r");
+ if (!stream) {
+ return false;
+ }
+ defer (pclose(stream));
+
+ while (!feof(stream)) {
+ size_t n = fread(buffer, 1, 255, stream);
+ *output = gb_string_append_length(*output, buffer, n);
+
+ if (ferror(stream)) {
+ return false;
+ }
+ }
+
+ if (build_context.show_system_calls) {
+ gb_printf_err("[SYSTEM CALL OUTPUT] %s -> %s\n", command, *output);
+ }
+
+ return true;
+}
+
gb_internal Array<String> setup_args(int argc, char const **argv) {
gbAllocator a = heap_allocator();