diff options
| author | Mark Naughton <mark@marknaughton.com> | 2023-04-24 14:26:53 +0100 |
|---|---|---|
| committer | Mark Naughton <mark@marknaughton.com> | 2023-04-24 14:26:53 +0100 |
| commit | 67b6a8ee89f5138f3e10d1d40111ac755ba34149 (patch) | |
| tree | eb86972434e232e0e1d4a148549163d18d564db9 /src/path.cpp | |
| parent | 780375d8654363f7de1eb95278b979d80a9a9775 (diff) | |
Add Windows equivalent of get_current_directory
Diffstat (limited to 'src/path.cpp')
| -rw-r--r-- | src/path.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/path.cpp b/src/path.cpp index baae94670..414a90c39 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -1,7 +1,9 @@ /*
Path handling utilities.
*/
+#if !defined(GB_SYSTEM_WINDOWS)
#include<unistd.h>
+#endif
gb_internal String remove_extension_from_path(String const &s) {
if (s.len != 0 && s.text[s.len-1] == '.') {
@@ -27,7 +29,9 @@ gb_internal String remove_directory_from_path(String const &s) { return substring(s, s.len-len, s.len);
}
+
// NOTE(Mark Naughton): getcwd as String
+#if !defined(GB_SYSTEM_WINDOWS)
gb_internal String get_current_directory(void) {
gbAllocator a = heap_allocator();
@@ -37,6 +41,17 @@ gb_internal String get_current_directory(void) { return make_string_c(cwd);
}
+#else
+gb_internal String get_current_directory(void) {
+ gbAllocator a = heap_allocator();
+
+ wchar_t cwd[256];
+ GetCurrentDirectoryW(256, cwd);
+
+ return make_string_c(cwd);
+}
+#endif
+
gb_internal bool path_is_directory(String path);
gb_internal String directory_from_path(String const &s) {
|