shell utils fixes
This commit is contained in:
@@ -5,11 +5,9 @@ local function get(path)
|
|||||||
path = fs.getDir(path)
|
path = fs.getDir(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
local label = fs.getDrive(path)
|
if fs.exists(path) then
|
||||||
|
|
||||||
if label then
|
|
||||||
local proxy = {
|
local proxy = {
|
||||||
getLabel = function() return label end,
|
getLabel = function() return fs.getDrive(path) end,
|
||||||
isReadOnly = function() return fs.isReadOnly(path) end,
|
isReadOnly = function() return fs.isReadOnly(path) end,
|
||||||
spaceTotal = function() return fs.getSize(path, true) + fs.getFreeSpace(path) end,
|
spaceTotal = function() return fs.getSize(path, true) + fs.getFreeSpace(path) end,
|
||||||
spaceUsed = function() return fs.getSize(path, true) end,
|
spaceUsed = function() return fs.getSize(path, true) end,
|
||||||
|
|||||||
@@ -85,10 +85,12 @@ local function visitor(rpath)
|
|||||||
|
|
||||||
if fs.isDirectory(spath) then
|
if fs.isDirectory(spath) then
|
||||||
local list_result = fs.list(spath)
|
local list_result = fs.list(spath)
|
||||||
for list_item in list_result do
|
if list_result then
|
||||||
local vtotal, vdirs = visitor(addTrailingSlash(rpath) .. list_item)
|
for list_item in list_result do
|
||||||
subtotal = subtotal + vtotal
|
local vtotal, vdirs = visitor(addTrailingSlash(rpath) .. list_item)
|
||||||
dirs = dirs + vdirs
|
subtotal = subtotal + vtotal
|
||||||
|
dirs = dirs + vdirs
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if dirs == 0 then -- no child dirs
|
if dirs == 0 then -- no child dirs
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ local function stat(names, index)
|
|||||||
end
|
end
|
||||||
local info = {}
|
local info = {}
|
||||||
info.key = name
|
info.key = name
|
||||||
|
info._path = name
|
||||||
info.path = name:sub(1, 1) == "/" and "" or names.path
|
info.path = name:sub(1, 1) == "/" and "" or names.path
|
||||||
info.full_path = fs.concat(info.path, name)
|
info.full_path = fs.concat(info.path, name)
|
||||||
info.isDir = fs.isDirectory(info.full_path)
|
info.isDir = fs.isDirectory(info.full_path)
|
||||||
@@ -247,6 +248,7 @@ local function display(names)
|
|||||||
local info = stat(names, index)
|
local info = stat(names, index)
|
||||||
local file_type = info.isLink and 'l' or info.isDir and 'd' or 'f'
|
local file_type = info.isLink and 'l' or info.isDir and 'd' or 'f'
|
||||||
local link_target = info.isLink and string.format(" -> %s", info.link:gsub("/+$", "") .. (info.isDir and "/" or "")) or ""
|
local link_target = info.isLink and string.format(" -> %s", info.link:gsub("/+$", "") .. (info.isDir and "/" or "")) or ""
|
||||||
|
_G._p = info
|
||||||
local write_mode = info.fs.isReadOnly() and '-' or 'w'
|
local write_mode = info.fs.isReadOnly() and '-' or 'w'
|
||||||
local size = formatSize(info.size)
|
local size = formatSize(info.size)
|
||||||
local format = "%s-r%s %+"..tostring(max_size_width)..'s '
|
local format = "%s-r%s %+"..tostring(max_size_width)..'s '
|
||||||
|
|||||||
Reference in New Issue
Block a user