ws-arch2: docs/guide sections (archive: LHA / ARJ / Zoo, encodings, disk images; font: bitmap fonts, Type 1 / EOT / Hershey) with tested snippets; tools/fixtures/docs_arch2.py inputs

This commit is contained in:
4DBug committed 2026-10-31 15:30:20 -05:00
1 parent 53b41c7275
commit cb5237aaa9
3 files changed
+189 -1

No files matched your search

+70
View File
@@ -272,6 +272,65 @@ assert(by["bin"].dir and by["bin/run.sh"].mode == 493 and by["run"].link == "bin
assert(F.archive.load(isoBytes, { prefer = "joliet" }).meta.iso.tree == "joliet")
```
## LHA, ARJ and Zoo
DOS-era archives read with their own compressors (`codecs/compress/Lzh`): LHA / LZH at header levels 0 to 3 with
lh0, lh1, lh4 to lh7, lhx and LArc's lzs / lz5 (Unix modes, symlinks, CRC-16 checked on `read`), ARJ methods 0 to 4
(CRC-32 checked) and Zoo's stored, LZW and lzh entries (deleted entries skipped). LHA also writes (level 2 headers,
stored data); ARJ and Zoo are read only.
```luau
local lzh = assert(F.archive.load(lzhBytes))
assert(lzh.format == "lha" and lzh:list()[1].method == "lh0") -- small files are stored
assert(buffer.tostring(assert(lzh:read("readme.txt"))) == "formats-luau retro archives\n")
local arj = assert(F.archive.load(arjBytes))
assert(arj:read("src/main.c"))
local zoo = assert(F.archive.load(zooBytes))
assert(zoo:list()[1].method == "lzw" and zoo:read("readme.txt"))
local stored = assert(F.save(lzh, nil, { format = "lha" })) -- level 2, lh0
assert(F.archive.load(stored):list()[1].method == "lh0")
```
## Encodings
Text and Mac encodings load as archives too: uuencode / xxencode / `begin-base64` blocks (`uu`), yEnc (multi-part
postings in one text are joined), BinHex 4.0, MacBinary I / II / III and AppleSingle / AppleDouble. All of them read
and write. Mac files keep the data fork as the entry `name` and a resource fork as `name .. ".rsrc"`
(`fork = "resource"`), with `macType`, `macCreator` and `finderFlags`. A single-file encoding is a stream, so a
uuencoded `.tar.gz` loads as the tar.
```luau
local uu = assert(F.archive.load(uuText))
assert(uu:list()[1].name == "readme.txt" and uu:list()[1].mode == 420) -- 420 = 0644
local a = F.format("binhex").new()
a:add("Read Me", "the data fork")
a:add("Read Me.rsrc", "resources")
a._byName["Read Me.rsrc"].fork = "resource"
local hqx = assert(a:write())
local back = assert(F.archive.load(hqx))
assert(back:list()[2].fork == "resource" and buffer.tostring(back:read("Read Me")) == "the data fork")
local y = assert(F.save(uu, nil, { format = "yenc" }))
assert(string.sub(buffer.tostring(y), 1, 8) == "=ybegin ")
```
## Disk images
Floppy and disk images list their files: Commodore D64 / D71 / D81 (PETSCII names as VICE's c1541 shows them,
`type` = `prg` / `seq` / `usr` / `rel`, disk name and id in `meta`), Amiga ADF (OFS / FFS, international and
directory-cache modes, protection bits, comments, links) and FAT12 / FAT16 / FAT32 images (VFAT long names; a
hard-disk image opens its first FAT partition, `partition` picks another). D64 and FAT floppies also write.
```luau
local d64 = assert(F.archive.load(d64Bytes))
assert(d64.meta.disk == "games" and d64:list()[1].type == "prg")
local adf = assert(F.archive.load(adfBytes))
assert(adf.meta.volume == "Work" and adf.meta.fs == "ffs" and adf:read("s/readme"))
local fat = assert(F.archive.load(floppyBytes))
assert(fat.meta.fat == 12 and fat.meta.label == "DOCS" and fat:read("src/main.c"))
local floppy = assert(F.save(adf, nil, { format = "fat", size = 720 })) -- copy the ADF's files to a FAT floppy
assert(F.archive.load(floppy):read("s/readme"))
```
## Formats
| Format | Read | Write | Notes |
@@ -290,6 +349,17 @@ assert(F.archive.load(isoBytes, { prefer = "joliet" }).meta.iso.tree == "joliet"
| compress (`.Z`, `.taz`) | yes | yes | single stream; 9..16-bit LZW |
| LZ4 (`.lz4`) | yes | yes | single stream; frames, legacy frames, XXH32 checks; no dictionaries |
| ISO 9660 (`.iso`) | yes | - | Joliet, Rock Ridge, El Torito, multi-extent; no UDF |
| LHA (`.lzh`, `.lha`, `.lzs`) | yes | yes | levels 0-3; lh0 / lh1 / lh4-lh7 / lhx / lzs / lz5; writes stored level 2 |
| ARJ (`.arj`) | yes | - | methods 0-4; no garbled entries, no multi-volume |
| Zoo (`.zoo`) | yes | - | stored / LZW / lzh |
| uuencode / xxencode (`.uu`, `.xxe`) | yes | yes | several blocks per text; GNU `begin-base64` too |
| yEnc (`.yenc`) | yes | yes | multi-part postings in one text |
| BinHex 4.0 (`.hqx`) | yes | yes | data and resource forks |
| MacBinary (`.bin`) | yes | yes | I / II / III; writes III |
| AppleSingle / AppleDouble | yes | yes | versions 1 and 2 |
| C64 disks (`.d64`, `.d71`, `.d81`) | yes | yes | PETSCII names; no GEOS VLIR |
| Amiga disks (`.adf`) | yes | - | OFS / FFS; no long-name (DOS\\6 / 7) volumes |
| FAT images (`.img`, `.ima`) | yes | yes | FAT12 / 16 / 32, VFAT names, MBR partitions; writes FAT12 floppies |
Full capability list: [FORMATS.md](../FORMATS.md).