aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-06-06 13:02:16 +0100
committergingerBill <bill@gingerbill.org>2024-06-06 13:02:16 +0100
commitc4ef8e7f6ceb4e2ce5d4869931d8f82afc1eb44c (patch)
treeb7adc511b3c0bc88b17def7a334424baf8829f8c /src/main.cpp
parent155516b897450ec265cfb53b6e32db90f15544f5 (diff)
parent9b66b0c8e6a934a1dc4ab68cfc02652e7a26c179 (diff)
Merge branch 'master' of https://github.com/odin-lang/Odin
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();