Browse Source

Merge pull request #3998 from zen3ger/os2-temp_file_linux

[os2] Add missing temp_file implementation for Linux
gingerBill 1 year ago
parent
commit
83599957b1
1 changed files with 7 additions and 4 deletions
  1. 7 4
      core/os/os2/temp_file_linux.odin

+ 7 - 4
core/os/os2/temp_file_linux.odin

@@ -3,8 +3,11 @@ package os2
 
 import "base:runtime"
 
-
-_temp_dir :: proc(allocator: runtime.Allocator) -> (string, Error) {
-	//TODO
-	return "", nil
+_temp_dir :: proc(allocator: runtime.Allocator) -> (string, runtime.Allocator_Error) {
+	TEMP_ALLOCATOR_GUARD()
+	tmpdir := get_env("TMPDIR", temp_allocator())
+	if tmpdir == "" {
+		tmpdir = "/tmp"
+	}
+	return clone_string(tmpdir, allocator)
 }