mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 04:38:16 +00:00
Add win32.get_cwd to return the current working directory
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -108,6 +108,8 @@ File_Attribute_Data :: struct {
|
||||
file_size_low: u32,
|
||||
}
|
||||
|
||||
// NOTE(Jeroen): The widechar version might want at least the 32k MAX_PATH_WIDE
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findfirstfilew#parameters
|
||||
Find_Data_W :: struct{
|
||||
file_attributes: u32,
|
||||
creation_time: Filetime,
|
||||
@@ -798,6 +800,7 @@ is_key_down :: inline proc(key: Key_Code) -> bool { return get_async_key_state(i
|
||||
|
||||
|
||||
MAX_PATH :: 0x00000104;
|
||||
MAX_PATH_WIDE :: 0x8000;
|
||||
|
||||
HANDLE_FLAG_INHERIT :: 1;
|
||||
HANDLE_FLAG_PROTECT_FROM_CLOSE :: 2;
|
||||
|
||||
Reference in New Issue
Block a user