1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-14 17:29:59 +00:00

extended file listing

This commit is contained in:
kepler155c@gmail.com 2017-08-05 04:17:06 -04:00
parent a1660fd073
commit c21afd2875
8 changed files with 34 additions and 47 deletions

View File

@ -1,7 +1,7 @@
local linkfs = { } local linkfs = { }
local methods = { 'exists', 'getFreeSpace', 'getSize', local methods = { 'exists', 'getFreeSpace', 'getSize',
'isDir', 'isReadOnly', 'list', 'makeDir', 'open', 'getDrive' } 'isDir', 'isReadOnly', 'list', 'listEx', 'makeDir', 'open', 'getDrive' }
for _,m in pairs(methods) do for _,m in pairs(methods) do
linkfs[m] = function(node, dir, ...) linkfs[m] = function(node, dir, ...)

View File

@ -29,7 +29,7 @@ local function remoteCommand(node, msg)
error('netfs: Connection failed', 2) error('netfs: Connection failed', 2)
end end
local methods = { 'delete', 'exists', 'getFreeSpace', 'makeDir' } local methods = { 'delete', 'exists', 'getFreeSpace', 'makeDir', 'list', 'listEx' }
local function resolveDir(dir, node) local function resolveDir(dir, node)
dir = dir:gsub(node.mountPoint, '', 1) dir = dir:gsub(node.mountPoint, '', 1)
@ -125,16 +125,6 @@ function netfs.find(node, spec)
return list return list
end end
function netfs.list(node, dir, full)
dir = resolveDir(dir, node)
local r = remoteCommand(node, {
fn = 'list',
args = { dir, full },
})
return r
end
function netfs.move(node, s, t) function netfs.move(node, s, t)
s = resolveDir(s, node) s = resolveDir(s, node)
t = resolveDir(t, node) t = resolveDir(t, node)

View File

@ -47,18 +47,8 @@ end
function ramfs.list(node, dir, full) function ramfs.list(node, dir, full)
if node.nodes and node.mountPoint == dir then if node.nodes and node.mountPoint == dir then
local files = { } local files = { }
if full then for k,v in pairs(node.nodes) do
for f,n in pairs(node.nodes) do table.insert(files, k)
table.insert(files, {
name = f,
isDir = fs.isDir(fs.combine(dir, f)),
size = fs.getSize(fs.combine(dir, f)),
})
end
else
for k,v in pairs(node.nodes) do
table.insert(files, k)
end
end end
return files return files
end end

View File

@ -130,7 +130,7 @@ function MEProvider:insert(slot, qty)
print(m) print(m)
Logger.log('MEProvider', 'Insert failed, trying again') Logger.log('MEProvider', 'Insert failed, trying again')
sleep(1) sleep(1)
s, m = pcall(function() self.pullItem('up', slot, qty) end) s, m = pcall(function() self.pullItem(self.oside, slot, qty) end)
if not s and m then if not s and m then
print('MEProvider:pullItem') print('MEProvider:pullItem')
print(m) print(m)

View File

@ -204,7 +204,7 @@ function Browser:updateDirectory(dir)
dir.totalSize = 0 dir.totalSize = 0
Util.clear(dir.files) Util.clear(dir.files)
local files = fs.list(dir.name, true) local files = fs.listEx(dir.name)
if files then if files then
dir.size = #files dir.size = #files
for _, file in pairs(files) do for _, file in pairs(files) do

View File

@ -67,7 +67,7 @@ while true do
while true do while true do
local e = Event.pullEvent() local e = Event.pullEvent()
if e == 'terminate' then if e[1] == 'terminate' then
break break
end end
if not socket.connected then if not socket.connected then

View File

@ -44,25 +44,6 @@ function nativefs.list(node, dir, full)
error('Not a directory') error('Not a directory')
end end
if full then
local t = { }
pcall(function()
for _,f in ipairs(files) do
local fullName = fs.combine(dir, f)
local file = {
name = f,
isDir = fs.isDir(fullName),
isReadOnly = fs.isReadOnly(fullName),
}
if not file.isDir then
file.size = fs.getSize(fullName)
end
table.insert(t, file)
end
end)
return t
end
return files return files
end end
@ -163,6 +144,32 @@ function fs.complete(partial, dir, includeFiles, includeSlash)
return fs.native.complete(partial, dir, includeFiles, includeSlash) return fs.native.complete(partial, dir, includeFiles, includeSlash)
end end
function fs.listEx(dir)
local node = getNode(dir)
if node.fs.listEx then
return node.fs.listEx(node, dir)
end
local t = { }
local files = node.fs.list(node, dir)
pcall(function()
for _,f in ipairs(files) do
local fullName = fs.combine(dir, f)
local file = {
name = f,
isDir = fs.isDir(fullName),
isReadOnly = fs.isReadOnly(fullName),
}
if not file.isDir then
file.size = fs.getSize(fullName)
end
table.insert(t, file)
end
end)
return t
end
function fs.copy(s, t) function fs.copy(s, t)
local sp = getNode(s) local sp = getNode(s)
local tp = getNode(t) local tp = getNode(t)

View File

@ -64,7 +64,7 @@ Event.addRoutine(function()
while true do while true do
local socket = Socket.server(139) local socket = Socket.server(139)
Event.addRoutine('samba_connection', function() Event.addRoutine(function()
print('samba: connection from ' .. socket.dhost) print('samba: connection from ' .. socket.dhost)
sambaConnection(socket) sambaConnection(socket)
print('samba: closing connection to ' .. socket.dhost) print('samba: closing connection to ' .. socket.dhost)