summaryrefslogtreecommitdiff
path: root/xmake/core/base/path.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2018-07-11 23:57:06 +0800
committerruki <[email protected]>2018-07-11 17:42:36 +0800
commit9bf2dfab4b53cb2b804bdb599b13b25e104d4b3f (patch)
tree610b335c94fb082eb1cd5b1b10f8c20b512e1b6b /xmake/core/base/path.lua
parent3365fc7ea36a050a3cfba771b78c48d44cb8a6e1 (diff)
improve find_path
Diffstat (limited to 'xmake/core/base/path.lua')
-rw-r--r--xmake/core/base/path.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua
index 4b8914ef5..340d57b83 100644
--- a/xmake/core/base/path.lua
+++ b/xmake/core/base/path.lua
@@ -109,5 +109,15 @@ function path.seperator()
end
end
+-- convert path pattern to a lua pattern
+function path.pattern(pattern)
+ pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
+ pattern = pattern:gsub("%*%*", "\001")
+ pattern = pattern:gsub("%*", "\002")
+ pattern = pattern:gsub("\001", ".*")
+ pattern = pattern:gsub("\002", "[^/]*")
+ return pattern
+end
+
-- return module: path
return path