Compare commits

..

No commits in common. "c24689d1a64c06cce4bf13bf1452fedad4051b4d" and "d3c053b6614d4d6658459b6ecf742c26ab207a0c" have entirely different histories.

2 changed files with 4 additions and 51 deletions

View File

@ -1,49 +0,0 @@
local vcomponent = require "vcomponent"
local component = require "component"
local diskpart = require "diskpart"
local event = require "event"
local listeners = {}
local function attachDrive(_,a,t)
if t ~= "drive" then return end
for k,v in ipairs(diskpart.getPartitions(a)) do
if v[4] > 0 then
vcomponent.register(string.format("%s/%i",a,k), "partition", diskpart.proxyPartition(a, k))
local w,l = pcall(require,string.format("fs.%s",v[2]))
if w and l and l.mount then
local w, f = pcall(l.mount, string.format("%s/%i",a,k))
if w then
vcomponent.register(string.format("%s/%i/%s",a,k,v[2]), f.type or "filesystem", f)
end
end
end
end
end
local function detachDrive(_,a,t)
if t ~= "drive" then return end
for ca,t in component.list() do
if (t == "partition" or t == "filesystem") and ca:sub(1,a:len()) == a then
vcomponent.unregister(ca)
end
end
end
function start()
listeners[#listeners+1] = event.listen("component_added", attachDrive)
listeners[#listeners+1] = event.listen("component_removed", detachDrive)
for k,v in component.list("drive",true) do
attachDrive(nil,k,v)
end
end
function stop()
for k,v in ipairs(listeners) do
event.cancel(v)
listeners[k] = nil
end
for k,v in component.list("drive",true) do
detachDrive(nil,k,"drive")
end
end

View File

@ -38,14 +38,16 @@ local ftypes = {
dfext = 2,
ddir = 3,
ddex = 4,
tfile = 5,
text = 6,
dtfile = 5,
dtext = 6,
dlink = 7,
unused = 8,
file = 9,
fext = 10,
dir = 11,
dex = 12,
tfile = 13,
text = 14,
link = 15
}
```