summaryrefslogtreecommitdiff
path: root/xmake/core/base/path.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-10 00:57:05 +0800
committerruki <[email protected]>2022-03-10 00:57:05 +0800
commit205f1d2ae8281955b22b868eb16741a86e44da58 (patch)
treeda3661eef0fe90aee853ae207fdb61727436d98b /xmake/core/base/path.lua
parent01afb1c8e997a4ce98bf107393101ea4cbb7e26b (diff)
add path.normalize
Diffstat (limited to 'xmake/core/base/path.lua')
-rw-r--r--xmake/core/base/path.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua
index ede2c36eb..49850c42b 100644
--- a/xmake/core/base/path.lua
+++ b/xmake/core/base/path.lua
@@ -24,6 +24,20 @@ local path = path or {}
-- load modules
local string = require("base/string")
+-- path.translate:
+-- - transform the path separator
+-- - expand the user directory with the prefix: ~
+-- - remove tail separator
+-- - reduce the repeat path separator, "////" => "/"
+--
+-- path.normalize:
+-- - reduce "././" => "."
+-- - reduce "/xxx/.." => "/"
+--
+function path.normalize(p)
+ return path.translate(p, {normalize = true})
+end
+
-- get the filename of the path
function path.filename(p, sep)
local i = 0