made fs.lua support relative paths

This commit is contained in:
Izaya 2019-01-02 16:40:55 +11:00
parent 2f48091a07
commit 7615cf67dc

View File

@ -10,6 +10,8 @@ function fs.segments(path)
return segments
end
function fs.resolve(path)
if not path or path == "." then path = os.getenv("PWD") end
if path:sub(1,1) ~= "/" then path=(os.getenv("PWD") or "").."/"..path end
local segments, rpath = fs.segments(path), "/"
for i = 2, #segments do
rpath = rpath .. segments[i] .. "/"