mirror of
https://github.com/kepler155c/opus
synced 2025-03-01 15:20:01 +00:00
extended file listing
This commit is contained in:
parent
a1660fd073
commit
c21afd2875
@ -1,7 +1,7 @@
|
||||
local linkfs = { }
|
||||
|
||||
local methods = { 'exists', 'getFreeSpace', 'getSize',
|
||||
'isDir', 'isReadOnly', 'list', 'makeDir', 'open', 'getDrive' }
|
||||
'isDir', 'isReadOnly', 'list', 'listEx', 'makeDir', 'open', 'getDrive' }
|
||||
|
||||
for _,m in pairs(methods) do
|
||||
linkfs[m] = function(node, dir, ...)
|
||||
|
@ -29,7 +29,7 @@ local function remoteCommand(node, msg)
|
||||
error('netfs: Connection failed', 2)
|
||||
end
|
||||
|
||||
local methods = { 'delete', 'exists', 'getFreeSpace', 'makeDir' }
|
||||
local methods = { 'delete', 'exists', 'getFreeSpace', 'makeDir', 'list', 'listEx' }
|
||||
|
||||
local function resolveDir(dir, node)
|
||||
dir = dir:gsub(node.mountPoint, '', 1)
|
||||
@ -125,16 +125,6 @@ function netfs.find(node, spec)
|
||||
return list
|
||||
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)
|
||||
s = resolveDir(s, node)
|
||||
t = resolveDir(t, node)
|
||||
|
@ -47,18 +47,8 @@ end
|
||||
function ramfs.list(node, dir, full)
|
||||
if node.nodes and node.mountPoint == dir then
|
||||
local files = { }
|
||||
if full then
|
||||
for f,n in pairs(node.nodes) do
|
||||
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
|
||||
for k,v in pairs(node.nodes) do
|
||||
table.insert(files, k)
|
||||
end
|
||||
return files
|
||||
end
|
||||
|
@ -130,7 +130,7 @@ function MEProvider:insert(slot, qty)
|
||||
print(m)
|
||||
Logger.log('MEProvider', 'Insert failed, trying again')
|
||||
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
|
||||
print('MEProvider:pullItem')
|
||||
print(m)
|
||||
|
@ -204,7 +204,7 @@ function Browser:updateDirectory(dir)
|
||||
dir.totalSize = 0
|
||||
Util.clear(dir.files)
|
||||
|
||||
local files = fs.list(dir.name, true)
|
||||
local files = fs.listEx(dir.name)
|
||||
if files then
|
||||
dir.size = #files
|
||||
for _, file in pairs(files) do
|
||||
|
@ -67,7 +67,7 @@ while true do
|
||||
|
||||
while true do
|
||||
local e = Event.pullEvent()
|
||||
if e == 'terminate' then
|
||||
if e[1] == 'terminate' then
|
||||
break
|
||||
end
|
||||
if not socket.connected then
|
||||
|
@ -44,25 +44,6 @@ function nativefs.list(node, dir, full)
|
||||
error('Not a directory')
|
||||
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
|
||||
end
|
||||
|
||||
@ -163,6 +144,32 @@ function fs.complete(partial, dir, includeFiles, includeSlash)
|
||||
return fs.native.complete(partial, dir, includeFiles, includeSlash)
|
||||
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)
|
||||
local sp = getNode(s)
|
||||
local tp = getNode(t)
|
||||
|
@ -64,7 +64,7 @@ Event.addRoutine(function()
|
||||
while true do
|
||||
local socket = Socket.server(139)
|
||||
|
||||
Event.addRoutine('samba_connection', function()
|
||||
Event.addRoutine(function()
|
||||
print('samba: connection from ' .. socket.dhost)
|
||||
sambaConnection(socket)
|
||||
print('samba: closing connection to ' .. socket.dhost)
|
||||
|
Loading…
x
Reference in New Issue
Block a user