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