def cd.err
bend-kit-archive@0.5.1.0 · archive.bend:168
import bend-kit-archive@0.5.1.0/archive.bend as Archive
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
168
169def cd.err(+h: List<&2, U32>, +p: U32, +end: U32) -> Maybe<&2, String>:
170 +method = u16(h, 10)
171 +packed = u32(h, 20)
172 +size = u32(h, 24)
173 +rest = (u16(h, 28) + u16(h, 30) + u16(h, 32) : U32)
174 +zip64 = Bool.or(Bool.or(U32.is_eq(packed, 4294967295), U32.is_eq(size, 4294967295)), U32.is_eq(u32(h, 42), 4294967295))
175 why(U32.is_eq(u32(h, 0), 33639248), "bad central directory header signature",
176 why(Bool.not(encrypted(u16(h, 8))), "encrypted entries are unsupported",
177 why(supported(method), "unsupported compression method " ++ U32.show(method),
178 why(Bool.not(zip64), "ZIP64 is unsupported",
179 why(U32.is_eq(u16(h, 34), 0), "multi-disk ZIP is unsupported",
180 why(Bytes.fits(end, (p + 46 : U32), rest), "central directory header runs past the directory",
181 why(Bool.or(U32.is_eq(method, 8), U32.is_eq(packed, size)), "stored entry sizes differ", None{})))))))