summaryrefslogtreecommitdiffstats
path: root/aconf/path.lua
diff options
context:
space:
mode:
Diffstat (limited to 'aconf/path.lua')
-rw-r--r--aconf/path.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/aconf/path.lua b/aconf/path.lua
index 4e289f5..8091a35 100644
--- a/aconf/path.lua
+++ b/aconf/path.lua
@@ -1,8 +1,9 @@
--[[
-Copyright (c) 2012-2015 Kaarle Ritvanen
+Copyright (c) 2012-2016 Kaarle Ritvanen
See LICENSE file for license details
--]]
+--- @module aconf.model
local M = {}
local map = require('aconf.util').map
@@ -26,12 +27,25 @@ function M.escape(comp)
end
+--- joins a number of already escaped path components into a single
+--- path.
+-- @function path.rawjoin
+-- @tparam string p1 path component
+-- @tparam ?string p2 path component
+-- @tparam ?string ... path component
+-- @treturn string path
function M.rawjoin(p1, p2, ...)
if not p2 then return p1 end
if not M.is_absolute(p2) then p2 = '/'..p2 end
return M.rawjoin((p1 == '/' and '' or p1)..p2, ...)
end
+--- appends a number of additional components to a path. The appended
+-- components are escaped first.
+-- @function path.join
+-- @tparam string parent path
+-- @tparam ?string ... path component
+-- @treturn string path
function M.join(parent, ...)
local args = map(function(c) return M.escape(c) end, {...})
if parent > '' then table.insert(args, 1, parent) end