@@ -42,12 +42,13 @@ export class Header {
4242 if ( ! buf || ! ( buf . length >= off + 512 ) ) {
4343 throw new Error ( 'need 512 bytes for header' ) ;
4444 }
45- this . path = decString ( buf , off , 100 ) ;
46- this . mode = decNumber ( buf , off + 100 , 8 ) ;
47- this . uid = decNumber ( buf , off + 108 , 8 ) ;
48- this . gid = decNumber ( buf , off + 116 , 8 ) ;
49- this . size = decNumber ( buf , off + 124 , 12 ) ;
50- this . mtime = decDate ( buf , off + 136 , 12 ) ;
45+ this . path = ex ?. path ?? decString ( buf , off , 100 ) ;
46+ this . mode = ex ?. mode ?? gex ?. mode ?? decNumber ( buf , off + 100 , 8 ) ;
47+ this . uid = ex ?. uid ?? gex ?. uid ?? decNumber ( buf , off + 108 , 8 ) ;
48+ this . gid = ex ?. gid ?? gex ?. gid ?? decNumber ( buf , off + 116 , 8 ) ;
49+ this . size = ex ?. size ?? gex ?. size ?? decNumber ( buf , off + 124 , 12 ) ;
50+ this . mtime =
51+ ex ?. mtime ?? gex ?. mtime ?? decDate ( buf , off + 136 , 12 ) ;
5152 this . cksum = decNumber ( buf , off + 148 , 12 ) ;
5253 // if we have extended or global extended headers, apply them now
5354 // See https://github.com/npm/node-tar/pull/187
@@ -75,11 +76,15 @@ export class Header {
7576 this . linkpath = decString ( buf , off + 157 , 100 ) ;
7677 if ( buf . subarray ( off + 257 , off + 265 ) . toString ( ) ===
7778 'ustar\u000000' ) {
78- this . uname = decString ( buf , off + 265 , 32 ) ;
79- this . gname = decString ( buf , off + 297 , 32 ) ;
8079 /* c8 ignore start */
81- this . devmaj = decNumber ( buf , off + 329 , 8 ) ?? 0 ;
82- this . devmin = decNumber ( buf , off + 337 , 8 ) ?? 0 ;
80+ this . uname =
81+ ex ?. uname ?? gex ?. uname ?? decString ( buf , off + 265 , 32 ) ;
82+ this . gname =
83+ ex ?. gname ?? gex ?. gname ?? decString ( buf , off + 297 , 32 ) ;
84+ this . devmaj =
85+ ex ?. devmaj ?? gex ?. devmaj ?? decNumber ( buf , off + 329 , 8 ) ?? 0 ;
86+ this . devmin =
87+ ex ?. devmin ?? gex ?. devmin ?? decNumber ( buf , off + 337 , 8 ) ?? 0 ;
8388 /* c8 ignore stop */
8489 if ( buf [ off + 475 ] !== 0 ) {
8590 // definitely a prefix, definitely >130 chars.
@@ -91,8 +96,12 @@ export class Header {
9196 if ( prefix ) {
9297 this . path = prefix + '/' + this . path ;
9398 }
94- this . atime = decDate ( buf , off + 476 , 12 ) ;
95- this . ctime = decDate ( buf , off + 488 , 12 ) ;
99+ /* c8 ignore start */
100+ this . atime =
101+ ex ?. atime ?? gex ?. atime ?? decDate ( buf , off + 476 , 12 ) ;
102+ this . ctime =
103+ ex ?. ctime ?? gex ?. ctime ?? decDate ( buf , off + 488 , 12 ) ;
104+ /* c8 ignore stop */
96105 }
97106 }
98107 let sum = 8 * 0x20 ;
0 commit comments