mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-25 08:43:58 +00:00
Use TMPDIR env var if available to get the temp dir name (#11443) [bugfix]
Additionally, use normalizePathEnd to suffix the dir name with "/" or "\" as appropriate for the current OS. Fixes https://github.com/nim-lang/Nim/issues/11439.
This commit is contained in:
committed by
Andreas Rumpf
parent
94177f7357
commit
2334680b3d
@@ -333,3 +333,15 @@ block ospaths:
|
||||
doAssert joinPath("", "lib") == "lib"
|
||||
doAssert joinPath("", "/lib") == unixToNativePath"/lib"
|
||||
doAssert joinPath("usr/", "/lib") == unixToNativePath"usr/lib"
|
||||
|
||||
block getTempDir:
|
||||
block TMPDIR:
|
||||
# TMPDIR env var is not used if either of these are defined.
|
||||
when not (defined(tempDir) or defined(windows) or defined(android)):
|
||||
if existsEnv("TMPDIR"):
|
||||
let origTmpDir = getEnv("TMPDIR")
|
||||
putEnv("TMPDIR", "/mytmp")
|
||||
doAssert getTempDir() == "/mytmp/"
|
||||
putEnv("TMPDIR", origTmpDir)
|
||||
else:
|
||||
doAssert getTempDir() == "/tmp/"
|
||||
|
||||
Reference in New Issue
Block a user