temp_file_windows.odin 655 B

1234567891011121314151617181920212223242526272829
  1. //+private
  2. package os2
  3. import win32 "core:sys/windows"
  4. _create_temp :: proc(dir, pattern: string) -> (Handle, Error) {
  5. return 0, nil
  6. }
  7. _mkdir_temp :: proc(dir, pattern: string, allocator := context.allocator) -> (string, Error) {
  8. return "", nil
  9. }
  10. _temp_dir :: proc(allocator := context.allocator) -> string {
  11. b := make([dynamic]u16, u32(win32.MAX_PATH), context.temp_allocator)
  12. for {
  13. n := win32.GetTempPathW(u32(len(b)), raw_data(b))
  14. if n > u32(len(b)) {
  15. resize(&b, int(n))
  16. continue
  17. }
  18. if n == 3 && b[1] == ':' && b[2] == '\\' {
  19. } else if n > 0 && b[n-1] == '\\' {
  20. n -= 1
  21. }
  22. return win32.utf16_to_utf8(b[:n], allocator)
  23. }
  24. }