(raw: RawHeader)
| 1305 | } |
| 1306 | |
| 1307 | private toHeader(raw: RawHeader): Header { |
| 1308 | // The records of the entry's own extended header override global ones |
| 1309 | const records = this.global === undefined |
| 1310 | ? this.pax |
| 1311 | : this.pax === undefined |
| 1312 | ? this.global |
| 1313 | : new Map([...this.global, ...this.pax]) |
| 1314 | const rest = records === undefined ? noPax : applyPax(raw, records) |
| 1315 | // Empty GNU long names are ignored, as in Go |
| 1316 | if (this.longName !== "") raw.path = this.longName |
| 1317 | if (this.longLink !== "") raw.linkTarget = this.longLink |
| 1318 | this.pax = undefined |
| 1319 | this.longName = "" |
| 1320 | this.longLink = "" |
| 1321 | if (!(Math.abs(raw.mtimeMillis) <= MAX_DATE_MILLIS)) { |
| 1322 | throw invalidHeader("mtime is out of range") |
| 1323 | } |
| 1324 | const type = typeOf(raw.typeflag, raw.path) |
| 1325 | const header: Types.Mutable<Header> = { |
| 1326 | path: raw.path, |
| 1327 | type, |
| 1328 | typeflag: raw.typeflag, |
| 1329 | size: isHeaderOnly(type) ? 0 : raw.size, |
| 1330 | mode: raw.mode & PERMISSION_BITS, |
| 1331 | uid: raw.uid, |
| 1332 | gid: raw.gid, |
| 1333 | uname: raw.uname, |
| 1334 | gname: raw.gname, |
| 1335 | mtime: new Date(raw.mtimeMillis), |
| 1336 | pax: rest |
| 1337 | } |
| 1338 | if (raw.linkTarget !== "") header.linkTarget = raw.linkTarget |
| 1339 | if (type === "CharDevice" || type === "BlockDevice") { |
| 1340 | header.devMajor = raw.devMajor |
| 1341 | header.devMinor = raw.devMinor |
| 1342 | } |
| 1343 | return header |
| 1344 | } |
| 1345 | } |
| 1346 | |
| 1347 | const SLAB_SIZE = 64 * 1024 |
no test coverage detected