Add win32.get_cwd to return the current working directory

This commit is contained in:
Jeroen van Rijn
2019-03-09 11:08:50 +01:00
parent 007a7989b8
commit d852b0c948
3 changed files with 34 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
package win32
import "core:strings";
foreign {
@(link_name="_wgetcwd") _get_cwd_wide :: proc(buffer: Wstring, buf_len: int) -> ^Wstring ---
}
get_cwd :: proc(allocator := context.temp_allocator) -> string {
buffer := make([]u16, MAX_PATH_WIDE, allocator);
_get_cwd_wide(Wstring(&buffer[0]), MAX_PATH_WIDE);
file := ucs2_to_utf8(buffer[:], allocator);
return strings.trim_right_null(file);
}