temp_file_windows.odin 681 B

1234567891011121314151617181920212223242526272829
  1. //+private
  2. package os2
  3. import "core:runtime"
  4. import win32 "core:sys/windows"
  5. _create_temp :: proc(dir, pattern: string) -> (^File, Error) {
  6. return nil, nil
  7. }
  8. _mkdir_temp :: proc(dir, pattern: string, allocator: runtime.Allocator) -> (string, Error) {
  9. return "", nil
  10. }
  11. _temp_dir :: proc(allocator: runtime.Allocator) -> (string, runtime.Allocator_Error) {
  12. n := win32.GetTempPathW(0, nil)
  13. if n == 0 {
  14. return "", nil
  15. }
  16. b := make([]u16, max(win32.MAX_PATH, n), _temp_allocator())
  17. n = win32.GetTempPathW(u32(len(b)), raw_data(b))
  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. }