-- Split a filename into [root, dir, basename]

function Path:_splitPath(filename: string)
	filename = self:normalizeSeparators(filename)
	local root = ""
	if self:isAbsolute(filename) or self:isDriveRelative(filename) then
		root = self:getRoot(filename)
		filename = filename:sub(root:len() + 1)
	end
	local trailing_slashes = filename:match("[" .. self.sep .. "]*$")
	if trailing_slashes then
		filename = filename:sub(1, -trailing_slashes:len() - 1)
	end
	local basename = filename:match("[^" .. self.sep .. "]+$") or ""
	local dir = basename and filename:sub(1, -basename:len() - 1) or filename
	return root, dir, basename
end
