temp_file_posix.odin 417 B

1234567891011121314151617181920
  1. //+private
  2. //+build darwin, netbsd, freebsd, openbsd
  3. package os2
  4. import "base:runtime"
  5. @(require)
  6. import "core:sys/posix"
  7. _temp_dir :: proc(allocator: runtime.Allocator) -> (string, runtime.Allocator_Error) {
  8. if tmp, ok := _lookup_env("TMPDIR", allocator); ok {
  9. return tmp, nil
  10. }
  11. when #defined(posix.P_tmpdir) {
  12. return clone_string(posix.P_tmpdir, allocator)
  13. }
  14. return clone_string("/tmp/", allocator)
  15. }