Skip to content

Commit

Permalink
lm.path support filesystem::path
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Mar 15, 2024
1 parent 4880b0c commit 4a27ff2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions scripts/pathutil.lua
Expand Up @@ -2,13 +2,20 @@ local fsutil = require "fsutil"

local mt = {}

local function create(path, accepted)
local function create_internal(path, accepted)
return setmetatable({
value = path,
accepted = accepted,
}, mt)
end

local function create(path)
if type(path) == "userdata" then
return create_internal(tostring(path), true)
end
return create_internal(path, nil)
end

local function path_normalize(base, path)
path = tostring(path)
if path:sub(1, 1) ~= "$" then
Expand Down Expand Up @@ -53,16 +60,16 @@ end
function mt.__concat(lft, rhs)
if type(lft) == "string" then
local path = lft..rhs.value
return create(path, rhs.accepted)
return create_internal(path, rhs.accepted)
else
local path = lft.value..rhs
return create(path, lft.accepted)
return create_internal(path, lft.accepted)
end
end

function mt:__div(rhs)
local path = fsutil.join(self.value, rhs)
return create(path, self.accepted)
return create_internal(path, self.accepted)
end

return {
Expand Down
2 changes: 1 addition & 1 deletion scripts/version.lua
@@ -1 +1 @@
return "1.7"
return "1.8"

0 comments on commit 4a27ff2

Please sign in to comment.