temp_file_windows.odin 707 B

12345678910111213141516171819202122232425262728293031
  1. //+private
  2. package os2
  3. import "base: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. _TEMP_ALLOCATOR_GUARD()
  17. b := make([]u16, max(win32.MAX_PATH, n), _temp_allocator())
  18. n = win32.GetTempPathW(u32(len(b)), raw_data(b))
  19. if n == 3 && b[1] == ':' && b[2] == '\\' {
  20. } else if n > 0 && b[n-1] == '\\' {
  21. n -= 1
  22. }
  23. return win32.utf16_to_utf8(b[:n], allocator)
  24. }