Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Aug 6, 2024
1 parent db2de08 commit ee36258
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ export function decode(b: Uint8Array, options?: DecodingHeadOptions) {
const gid = decodeOctal(b, 116, 8)
const size = decodeOctal(b, 124, 12)
const mtime = decodeOctal(b, 136, 12)
let typeflag = b[156] as unknown as TypeFlag
// convert as enum
let typeflag = b[156] === 0 ? TypeFlag.AREG_TYPE : (b[156] - 48) + '' as unknown as TypeFlag
const linkname = b[157] === Magic.NULL_CHAR ? null : decodeString(b, 157, 100, filenameEncoding)
const uname = decodeString(b, 265, 32)
const gname = decodeString(b, 297, 32)
Expand Down
30 changes: 24 additions & 6 deletions src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class FastBytes {
if (size === 0) {
return new Uint8Array(0)
}

const elt = this.queue.peek()
if (!elt) {
throw new Error(FAST_BYTES_ERROR_MESSAGES.EXCEED_BYTES_LEN)
Expand Down Expand Up @@ -175,22 +174,41 @@ export class Extract {
})
}

private decodeHead() {
private scan() {
try {
const head = decode(this.matrix.shift(512), this.decodeOptions)
const r = this.matrix.shift(head.size)
return true
} catch (error) {
//
// console.log(error)

return false
}
}

// private decodeHead() {
// try {
// const head = decode(this.matrix.shift(512), this.decodeOptions)

// this.writer.emit('entry', head)
// // if (head) {
// // console.log(head)
// // }
// } catch (error) {
// //
// return [false, error]
// }
// return false
// }

private transport() {
console.log(this.matrix.bytesLen, 'x')
while (this.matrix.bytesLen > 0) {
//

if (this.matrix.bytesLen < 512) {
break
}
this.decodeHead()
if (!this.scan()) return
// if (!this.decodeHead()) return
}
//
// const reader = createReadbleStream({
Expand Down

0 comments on commit ee36258

Please sign in to comment.