Skip to content

Commit

Permalink
cleanup: remove unnecessary filesystem helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Sep 19, 2023
1 parent 0d6654f commit 26d5f21
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions lua/oil/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ M.is_absolute = function(dir)
end
end

M.abspath = function(path)
if not M.is_absolute(path) then
path = vim.fn.fnamemodify(path, ":p")
end
return path
end

---@param path string
---@param cb fun(err: nil|string)
M.touch = function(path, cb)
Expand Down Expand Up @@ -80,38 +73,6 @@ M.os_to_posix_path = function(path)
end
end

--- Returns true if candidate is a subpath of root, or if they are the same path.
---@param root string
---@param candidate string
---@return boolean
M.is_subpath = function(root, candidate)
if candidate == "" then
return false
end
root = vim.fs.normalize(M.abspath(root))
-- Trim trailing "/" from the root
if root:find("/", -1) then
root = root:sub(1, -2)
end
candidate = vim.fs.normalize(M.abspath(candidate))
if M.is_windows then
root = root:lower()
candidate = candidate:lower()
end
if root == candidate then
return true
end
local prefix = candidate:sub(1, root:len())
if prefix ~= root then
return false
end

local candidate_starts_with_sep = candidate:find("/", root:len() + 1, true) == root:len() + 1
local root_ends_with_sep = root:find("/", root:len(), true) == root:len()

return candidate_starts_with_sep or root_ends_with_sep
end

local home_dir = assert(uv.os_homedir())

---@param path string
Expand Down

0 comments on commit 26d5f21

Please sign in to comment.