summaryrefslogtreecommitdiff
path: root/xmake/core/base/os.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2018-03-16 22:45:54 +0800
committerruki <[email protected]>2018-03-16 10:35:30 +0800
commita799d50c58621b7dccd0c2c646c24b06d4df191a (patch)
tree0cc187b27d83ec99fccaf01dec17a92cd294436d /xmake/core/base/os.lua
parent205132b53a8f0667f1dd5778555ce2c57be2e687 (diff)
improve tmpdir and stats
Diffstat (limited to 'xmake/core/base/os.lua')
-rw-r--r--xmake/core/base/os.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index c5b1a2867..96bf998dc 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -469,22 +469,24 @@ function os.tmpdir()
end
-- make sub-directory name
- local subdir = utils.ifelse(os._FAKEROOT, ".xmakefake", ".xmake")
+ local subdir = (os._FAKEROOT and ".xmakefake" or ".xmake") .. (os.uid().euid or "")
-- get a temporary directory for each user
- local tmpdir = path.join(os._tmpdir(), subdir .. (os.uid().euid or ""))
+ local tmpdir = path.join(os._tmpdir(), subdir, os.date("%y%m%d"))
- -- ensure this directory exist
+ -- ensure this directory exist and remove the previous directory
if not os.isdir(tmpdir) then
os.mkdir(tmpdir)
+ local predir = path.join(os._tmpdir(), subdir, os.date("%y%m%d", os.time() - 24 * 60 * 60))
+ if os.isdir(predir) then
+ os.rmdir(predir)
+ end
end
return tmpdir
end
-- generate the temporary file path
function os.tmpfile()
-
- -- make it
return path.join(os.tmpdir(), "_" .. (hash.uuid():gsub("-", "")))
end