From cbcf94669e138a1afcfc8d581257e81b138fbdb9 Mon Sep 17 00:00:00 2001 From: Mark Naughton Date: Mon, 24 Apr 2023 12:57:34 +0100 Subject: [PATCH] Add get_current_directory() --- src/path.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/path.cpp b/src/path.cpp index 49a2d4a4f..baae94670 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -1,6 +1,8 @@ /* Path handling utilities. */ +#include + gb_internal String remove_extension_from_path(String const &s) { if (s.len != 0 && s.text[s.len-1] == '.') { return s; @@ -25,6 +27,16 @@ gb_internal String remove_directory_from_path(String const &s) { return substring(s, s.len-len, s.len); } +// NOTE(Mark Naughton): getcwd as String +gb_internal String get_current_directory(void) { + gbAllocator a = heap_allocator(); + + char cwd[256]; + getcwd(cwd, 256); + + return make_string_c(cwd); +} + gb_internal bool path_is_directory(String path); gb_internal String directory_from_path(String const &s) {