Update error handling for os2 on windows

This commit is contained in:
gingerBill
2022-05-12 12:54:27 +01:00
parent ccb38c3dc6
commit bb4f108487
15 changed files with 310 additions and 191 deletions
+15 -15
View File
@@ -1,29 +1,29 @@
//+private
package os2
import "core:runtime"
import win32 "core:sys/windows"
_create_temp :: proc(dir, pattern: string) -> (^File, Error) {
return nil, nil
}
_mkdir_temp :: proc(dir, pattern: string, allocator := context.allocator) -> (string, Error) {
_mkdir_temp :: proc(dir, pattern: string, allocator: runtime.Allocator) -> (string, Error) {
return "", nil
}
_temp_dir :: proc(allocator := context.allocator) -> string {
b := make([dynamic]u16, u32(win32.MAX_PATH), context.temp_allocator)
for {
n := win32.GetTempPathW(u32(len(b)), raw_data(b))
if n > u32(len(b)) {
resize(&b, int(n))
continue
}
if n == 3 && b[1] == ':' && b[2] == '\\' {
} else if n > 0 && b[n-1] == '\\' {
n -= 1
}
return win32.utf16_to_utf8(b[:n], allocator)
_temp_dir :: proc(allocator: runtime.Allocator) -> string {
n := win32.GetTempPathW(0, nil)
if n == 0 {
return ""
}
b := make([]u16, max(win32.MAX_PATH, n), _temp_allocator())
n = win32.GetTempPathW(u32(len(b)), raw_data(b))
if n == 3 && b[1] == ':' && b[2] == '\\' {
} else if n > 0 && b[n-1] == '\\' {
n -= 1
}
return win32.utf16_to_utf8(b[:n], allocator)
}