summaryrefslogtreecommitdiff
path: root/xmake/core/base/path.lua
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-06-18 08:28:35 +0800
committerOpportunityLiu <[email protected]>2019-06-18 08:28:35 +0800
commit9c8b83a61fce275edd3808c54f36ba368378fa5d (patch)
tree13c33fc09353745d706bfccbc7e7fba9531b24ce /xmake/core/base/path.lua
parent284857c1a43ce61a9f5433d88414e539f2bdc02a (diff)
Support clang as cuda compiler
Diffstat (limited to 'xmake/core/base/path.lua')
-rw-r--r--xmake/core/base/path.lua22
1 files changed, 21 insertions, 1 deletions
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua
index 489f6b702..9499799f1 100644
--- a/xmake/core/base/path.lua
+++ b/xmake/core/base/path.lua
@@ -27,6 +27,10 @@ local string = require("base/string")
-- get the directory of the path
function path.directory(p)
+
+ -- check
+ assert(p)
+
local i = p:find_last("[/\\]")
if i then
if i > 1 then i = i - 1 end
@@ -38,6 +42,10 @@ end
-- get the filename of the path
function path.filename(p)
+
+ -- check
+ assert(p)
+
local i = p:find_last("[/\\]")
if i then
return p:sub(i + 1)
@@ -48,6 +56,10 @@ end
-- get the basename of the path
function path.basename(p)
+
+ -- check
+ assert(p)
+
local name = path.filename(p)
local i = name:find_last(".", true)
if i then
@@ -89,6 +101,10 @@ end
-- split path by the separator
function path.split(p)
+
+ -- check
+ assert(p)
+
return p:split("/\\")
end
@@ -104,13 +120,17 @@ end
-- the last character is the path seperator?
function path.islastsep(p)
+
+ -- check
+ assert(p)
+
local sep = p:sub(#p, #p)
return xmake._HOST == "windows" and (sep == '\\' or sep == '/') or (sep == '/')
end
-- convert path pattern to a lua pattern
function path.pattern(pattern)
-
+
-- translate wildcards, .e.g *, **
pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
pattern = pattern:gsub("%*%*", "\001")