MCPcopy Create free account
hub / github.com/Effect-TS/effect / localHeader

Function localHeader

packages/effect/src/encoding/Zip.ts:958–985  ·  view source on GitHub ↗
(record: EntryRecord)

Source from the content-addressed store, hash-verified

956}
957
958const localHeader = (record: EntryRecord): Uint8Array => {
959 const { zip64 } = record
960 const extraLength = (zip64 ? 20 : 0) + timestampLength(record)
961 const bytes = new Uint8Array(30 + record.name.length + extraLength)
962 const view = new DataView(bytes.buffer)
963 view.setUint32(0, LOCAL, true)
964 view.setUint16(4, zip64 ? VERSION_ZIP64 : VERSION, true)
965 view.setUint16(6, record.flags, true)
966 view.setUint16(8, record.method, true)
967 view.setUint16(10, record.time, true)
968 view.setUint16(12, record.date, true)
969 view.setUint32(14, record.crc, true)
970 view.setUint32(18, zip64 ? MAX32 : record.compressedSize, true)
971 view.setUint32(22, zip64 ? MAX32 : record.size, true)
972 view.setUint16(26, record.name.length, true)
973 view.setUint16(28, extraLength, true)
974 bytes.set(record.name, 30)
975 let at = 30 + record.name.length
976 if (zip64) {
977 view.setUint16(at, EXTRA_ZIP64, true)
978 view.setUint16(at + 2, 16, true)
979 setUint64(view, at + 4, record.size)
980 setUint64(view, at + 12, record.compressedSize)
981 at += 20
982 }
983 writeTimestamp(bytes, view, at, record)
984 return bytes
985}
986
987const dataDescriptor = (record: EntryRecord): Uint8Array => {
988 const wide = record.zip64

Callers 2

entryMethod · 0.70
beginMethod · 0.70

Calls 4

timestampLengthFunction · 0.85
setUint64Function · 0.85
writeTimestampFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected