summaryrefslogtreecommitdiff
path: root/xmake/core/base/path.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-22 19:19:39 +0800
committerruki <[email protected]>2022-05-22 19:19:39 +0800
commita3d82bd43a50906804597a86a9deea950c2e5adb (patch)
tree811a5049e80812beb0f9434a3e5cf93e0adae05d /xmake/core/base/path.lua
parent59b0d6109513a973815ff08a811305d70ec5fe01 (diff)
improve lex yacc rules
Diffstat (limited to 'xmake/core/base/path.lua')
-rw-r--r--xmake/core/base/path.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua
index 04c386c23..4f534bb50 100644
--- a/xmake/core/base/path.lua
+++ b/xmake/core/base/path.lua
@@ -26,6 +26,9 @@ local string = require("base/string")
local table = require("base/table")
local _instance = _instance or {}
+-- save original interfaces
+path._absolute = path._absolute or path.absolute
+
-- new a path
function _instance.new(p, transform)
local instance = table.inherit(_instance)
@@ -95,6 +98,10 @@ function _instance:directory()
return path.new(path.directory(self:str()), self._TRANSFORM)
end
+function _instance:absolute()
+ return path.new(path.absolute(self:str()), self._TRANSFORM)
+end
+
function _instance:join(...)
local items = {self:str()}
for _, item in ipairs(table.pack(...)) do
@@ -165,6 +172,12 @@ if not path.directory then
end
end
+-- get absolute path
+function path.absolute(p)
+ p = tostring(p)
+ return path._absolute(p)
+end
+
-- get the filename of the path
function path.filename(p, sep)
p = tostring(p)