@@ -87,7 +87,7 @@ const filename = fileURLToPath(import.meta.url);
8787 zipfile . addBuffer ( Buffer . from ( 'buffer' ) , 'b.txt' ) ;
8888 zipfile . addReadStream ( new BufferListStream ( ) . append ( 'stream' ) , 'c.txt' ) ;
8989 zipfile . addEmptyDirectory ( 'd/' ) ;
90- zipfile . addEmptyDirectory ( 'e' ) ;
90+ zipfile . addEmptyDirectory ( 'e' , { mode : 0o000644 } ) ;
9191 zipfile . end ( function ( finalSize ) {
9292 if ( finalSize !== - 1 ) throw new Error ( 'finalSize should be unknown' ) ;
9393 zipfile . outputStream . pipe ( new BufferListStream ( function ( err , data ) {
@@ -96,9 +96,21 @@ const filename = fileURLToPath(import.meta.url);
9696 if ( err ) throw err ;
9797 const entryNames = [ 'a.txt' , 'b.txt' , 'c.txt' , 'd/' , 'e/' ] ;
9898 zipfile . on ( 'entry' , function ( entry ) {
99+ const { fileName } = entry ;
99100 const expectedName = entryNames . shift ( ) ;
100- if ( entry . fileName !== expectedName ) {
101- throw new Error ( `unexpected entry fileName: ${ entry . fileName } , expected: ${ expectedName } ` ) ;
101+ if ( fileName !== expectedName ) {
102+ throw new Error ( `unexpected entry fileName: ${ fileName } , expected: ${ expectedName } ` ) ;
103+ }
104+ const mode = entry . externalFileAttributes >>> 16 ;
105+ if ( fileName . endsWith ( '/' ) ) {
106+ if ( ( mode & 0o040000 ) === 0 ) {
107+ throw new Error ( `directory expected to have S_IFDIR, found ${ mode . toString ( 8 ) } ` ) ;
108+ }
109+ if ( ( mode & 0o000111 ) === 0 ) {
110+ throw new Error ( `directory expected to have executable flags, found ${ mode . toString ( 8 ) } ` ) ;
111+ }
112+ } else if ( ( mode & 0o100000 ) === 0 ) {
113+ throw new Error ( `file expected to have S_IFREG, found ${ mode . toString ( 8 ) } ` ) ;
102114 }
103115 } ) ;
104116 zipfile . on ( 'end' , function ( ) {
0 commit comments