diff options
| author | ruki <[email protected]> | 2026-02-19 22:41:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-02-19 22:41:40 +0800 |
| commit | 8a0500d1fb9453fc5a8bebf9f859acadc1d8301f (patch) | |
| tree | e4d80b41276ab0dacd91b37fed72e23cd7d93320 | |
| parent | 562cd7187775c7b7184cc7da5fffd0dcc77550d3 (diff) | |
improve os.tmpdir
| -rw-r--r-- | xmake/core/base/os.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index d50ce19f2..b8ce09f68 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -200,6 +200,15 @@ function os._ramdir() return ramdir_root or nil end +-- if tmpdir_root is a symbolic link, os.tmpdir() may return a path that differs +-- from the path style returned by os.curdir() (e.g. on Haiku). +function os._resolve_tmpdir(tmpdir_root) + if os.islink(tmpdir_root) then + tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root + end + return tmpdir_root +end + -- set on change environments callback for scheduler function os._sched_chenvs_set(envs) os._SCHED_CHENVS = envs @@ -771,19 +780,14 @@ function os.tmpdir(opt) tmpdir_root = os._ROOT_TMPDIR if os._ROOT_TMPDIR == nil then tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() - -- TODO - if os.islink(tmpdir_root) then - tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root - end + tmpdir_root = os._resolve_tmpdir(tmpdir_root) os._ROOT_TMPDIR = tmpdir_root end else tmpdir_root = os._ROOT_TMPDIR_RAM if os._ROOT_TMPDIR_RAM == nil then tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() - if os.islink(tmpdir_root) then - tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root - end + tmpdir_root = os._resolve_tmpdir(tmpdir_root) os._ROOT_TMPDIR_RAM = tmpdir_root end end |
