shell utils fixes

This commit is contained in:
kepler155c@gmail.com
2019-04-08 09:31:13 -04:00
parent fba1546213
commit a16510e254
3 changed files with 10 additions and 8 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -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 '