mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 09:54:45 +00:00
Add get_current_directory()
This commit is contained in:
12
src/path.cpp
12
src/path.cpp
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
Path handling utilities.
|
||||
*/
|
||||
#include<unistd.h>
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user