summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2013-05-23 21:23:09 +0100
committerRichard Maw <richard.maw@gmail.com>2013-05-23 21:35:22 +0100
commit409015f2cd025fc2f9769f79eebf3d7e628e086b (patch)
tree304940d527ef04f3e7017fde68709dd6e1f48c7d
parent70aa8bc575257393b933dfd2e5cbe29e47ec3db0 (diff)
downloadgitano-409015f2cd025fc2f9769f79eebf3d7e628e086b.tar.bz2
util: add path_join function
This is like python's os.path.join. It is shorter to write `util.path_join("foo", "bar", "baz")` than `table.concat({"foo", "bar", "baz"}, "/")`, and I think it looks nicer. If any special path handling is later required, then it can go there.
-rw-r--r--lib/gitano/util.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua
index c8834d3..c5ff673 100644
--- a/lib/gitano/util.lua
+++ b/lib/gitano/util.lua
@@ -107,6 +107,10 @@ local function path_components(path)
return ret
end
+local function path_join(...)
+ return tconcat({...}, "/")
+end
+
local function dirname(path)
local t = path_components(path)
t[#t] = nil
@@ -321,6 +325,7 @@ return {
patesc = patesc,
path_components = path_components,
+ path_join = path_join,
dirname = dirname,
basename = basename,