@@ -79,7 +79,7 @@ var BufferList = require("bl");
7979 zipfile . addBuffer ( bufferFrom ( "buffer" ) , "b.txt" ) ;
8080 zipfile . addReadStream ( new BufferList ( ) . append ( "stream" ) , "c.txt" ) ;
8181 zipfile . addEmptyDirectory ( "d/" ) ;
82- zipfile . addEmptyDirectory ( "e" ) ;
82+ zipfile . addEmptyDirectory ( "e" , { mode : 0o644 } ) ;
8383 zipfile . end ( function ( finalSize ) {
8484 if ( finalSize !== - 1 ) throw new Error ( "finalSize should be unknown" ) ;
8585 zipfile . outputStream . pipe ( new BufferList ( function ( err , data ) {
@@ -92,6 +92,14 @@ var BufferList = require("bl");
9292 if ( entry . fileName !== expectedName ) {
9393 throw new Error ( "unexpected entry fileName: " + entry . fileName + ", expected: " + expectedName ) ;
9494 }
95+ var mode = entry . externalFileAttributes >>> 16 ;
96+ if ( / \/ $ / . test ( entry . fileName ) ) {
97+ // Directory file names end with '/'.
98+ if ( ! ( mode & 0o040000 ) ) throw new Error ( "directory expected to have S_IFDIR, found " + mode . toString ( 8 ) ) ;
99+ if ( ! ( mode & 0o111 ) ) throw new Error ( "directory expected to have executable flags, found " + mode . toString ( 8 ) ) ;
100+ } else {
101+ if ( ! ( mode & 0o100000 ) ) throw new Error ( "file expected to have S_IFREG, found " + mode . toString ( 8 ) ) ;
102+ }
95103 } ) ;
96104 zipfile . on ( "end" , function ( ) {
97105 if ( entryNames . length === 0 ) console . log ( "optional parameters and directories: pass" ) ;
0 commit comments