merge ws/arch2: cpio ar/deb rpm .Z lz4 iso lha arj zoo cab, uu/yenc/binhex/macbinary/applesingle, d64 adf fat, bdf pcf psf fon type1 eot hershey

This commit is contained in:
4DBug committed 2026-10-31 16:44:01 -05:00
commit b5cdd77a5b
115 files changed
+17373 -29

No files matched your search

+26 -7
View File
@@ -241,35 +241,54 @@ end
-- single-stream archives (gzip / zst / xz / bz2 / br: meta.stream) whose one entry sniffs as another archive (a
-- .tar.gz) load as that inner archive, with meta.compression = the outer format. opts.unwrap = false keeps the outer
-- one; an explicit opts.format also does.
-- one; an explicit opts.format also does. Package archives name their payload entry in meta.payload (a .deb's
-- data.tar.xz): they load as that inner archive too, with meta.container = the outer format and meta.outer = the
-- outer archive (its control data). A single-stream archive holding a .pcf / .psf(u) / .bdf font loads as the font.
local function unwrap(value: any, formatName: string, o: Options): any
if o.unwrap == false or o.format ~= nil or (o._depth or 0) >= 3 then
return value
end
if type(value) ~= "table" or value.kind ~= "archive" or type(value.meta) ~= "table" or not value.meta.stream then
if type(value) ~= "table" or value.kind ~= "archive" or type(value.meta) ~= "table" then
return value
end
local payload = value.meta.payload
if not value.meta.stream and type(payload) ~= "string" then
return value
end
local ok, list = pcall(value.list, value)
if not ok or type(list) ~= "table" or #list ~= 1 then
if not ok or type(list) ~= "table" or (#list ~= 1 and type(payload) ~= "string") or #list == 0 then
return value
end
local rok, inner = pcall(value.read, value, list[1].name)
local entryName = if type(payload) == "string" then payload else list[1].name
local rok, inner = pcall(value.read, value, entryName)
if not rok or type(inner) ~= "buffer" then
return value
end
local category = "archive"
local e = detect(inner, nil, "archive", nil)
local innerExt = Input.extension(entryName) or ""
if not e and value.meta.stream and (innerExt == "pcf" or innerExt == "psf" or innerExt == "psfu" or innerExt == "bdf") then
-- compressed bitmap fonts (.pcf.gz, .psf.gz, .bdf.gz: X11 and console font directories) load as the font
e = detect(inner, entryName, "font", nil)
category = "font"
end
if not e then
return value
end
local io = table.clone(o)
io.category = "archive"
io.name = list[1].name
io.category = category
io.name = entryName
io._depth = (o._depth or 0) + 1
local v = load(inner, io)
if type(v) ~= "table" or type(v.meta) ~= "table" then
return value
end
v.meta.compression = formatName
if type(payload) == "string" then
v.meta.container = formatName
v.meta.outer = value
else
v.meta.compression = formatName
end
return v
end