mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 03:54:20 -05:00
rewrote the whole index thing and made it possible to remove packages from the pkgfs index
This commit is contained in:
parent
3266c66fc4
commit
999d8e0387
@ -3,6 +3,7 @@ local w, lz16 = pcall(require, "liblz16")
|
|||||||
if not w then lz16 = nil end
|
if not w then lz16 = nil end
|
||||||
|
|
||||||
pkgfs = {}
|
pkgfs = {}
|
||||||
|
pkgfs.files = {}
|
||||||
local findex = {}
|
local findex = {}
|
||||||
local handles = {}
|
local handles = {}
|
||||||
local hc = 0
|
local hc = 0
|
||||||
@ -98,17 +99,35 @@ function pkgfs.component.close(handle)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function pkgfs.add(fname,comp) -- string boolean -- -- Add a package as specified in *fname* to the pkgfs component. If *comp* is true, read it as a LZ16-compressed package.
|
local function index()
|
||||||
if fname:sub(1,1) ~= "/" then
|
findex = {}
|
||||||
fname = "/"..fnormalize(os.getenv("PWD").."/"..fname)
|
for k,v in pairs(pkgfs.files) do
|
||||||
|
fname, comp = v[1], v[2]
|
||||||
|
if fname:sub(1,1) ~= "/" then
|
||||||
|
fname = "/"..fnormalize(os.getenv("PWD").."/"..fname)
|
||||||
|
end
|
||||||
|
local f = fopen(fname,comp)
|
||||||
|
if not f then error("unable to open file") end
|
||||||
|
print(fname)
|
||||||
|
for name, read, fsize in mtar.iter(f) do
|
||||||
|
findex[fnormalize(name)] = {fname,comp}
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
end
|
end
|
||||||
local f = fopen(fname,comp)
|
return true
|
||||||
if not fname then error("unable to open file") end
|
end
|
||||||
print(fname)
|
|
||||||
for name, read, fsize in mtar.iter(f) do
|
function pkgfs.add(fname,comp) -- string boolean -- boolean -- Add a package as specified in *fname* to the pkgfs component. If *comp* is true, read it as a LZ16-compressed package.
|
||||||
findex[fnormalize(name)] = {fname,comp}
|
pkgfs.files[#pkgfs.files+1] = {fname,comp}
|
||||||
|
return index()
|
||||||
|
end
|
||||||
|
function pkgfs.remove(fname) -- string -- boolean -- Removes the package specified by *fname* from the pkgfs index.
|
||||||
|
for k,v in pairs(pkgfs.files) do
|
||||||
|
if v[1] == fname then
|
||||||
|
table.remove(pkgfs.files,k)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
f:close()
|
return index()
|
||||||
end
|
end
|
||||||
|
|
||||||
fs.makeDirectory("/pkg")
|
fs.makeDirectory("/pkg")
|
||||||
|
Loading…
Reference in New Issue
Block a user