mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-14 07:13:14 +00:00
Add Windows equivalent of get_current_directory
This commit is contained in:
15
src/path.cpp
15
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) {
|
||||
|
||||
Reference in New Issue
Block a user