implement some leftover stuff in rtfs

This commit is contained in:
Izaya 2023-08-05 16:22:11 +10:00
parent fccd0d4983
commit afbf6eaa7a
1 changed files with 10 additions and 5 deletions

View File

@ -183,7 +183,6 @@ end
function proxy:dumpIndex()
print(" # ty init len end name")
for i, tp, st, sl, n in self:allIEntries() do
-- print(string.format("%2x %2x %4x %4x %4x %s",i,tp,st,sl,st+sl-1, n))
print(string.format("%2i %2i %4i %4i %4i %s",i,tp,st,sl,st+sl-1, n))
end
end
@ -266,9 +265,7 @@ function proxy:relocateFile(n,dest,loud)
-- modify any writing handles to write to the destination before doing anything
local realLen
for k,v in pairs(self.handles) do
print(n, v.ft[1])
if v.ft[1] == n and (v.w or v.a) then
print("found file handle")
v.ft[2] = dest
realLen = v.currentSector
end
@ -434,7 +431,7 @@ function rtfs.mount(d)
end
function p.isDirectory(name)
name = fnormalize(name)
return p:findIEntry(ftypes.directory, nil, nil, name) ~= nil
return name == "" and true or p:findIEntry(ftypes.directory, nil, nil, name) ~= nil
end
function p.size(name)
name = fnormalize(name)
@ -472,6 +469,11 @@ function rtfs.mount(d)
function p.makeDirectory(name)
name = fnormalize(name)
if #name < 1 or p:findIEntry(nil,nil,nil,name) then return false end
local seg = fs.segments(name)
for j = 1, #seg-1 do
p.makeDirectory(table.concat(seg, "/", 1, j))
end
if not p.isDirectory(table.concat(seg,"/",1,#seg-1)) then return false end
local ni = p:nextEntry()
p:writeIEntry(ni, ftypes.directory, 0, 0, name)
p:setISize(math.max(p.isize, ni))
@ -486,7 +488,10 @@ function rtfs.mount(d)
end
local fi, ft = p:findIEntry(ftypes.directory, nil, nil, name)
if fi then
error("removing dirs not implemented")
for _,f in ipairs(p.list(name)) do
p.remove(name.."/"..f)
end
p:writeIEntry(fi, ftypes.unused, 0, 0, "")
end
end
function p.rename(from, to)