@@ -278,7 +278,7 @@ function getEndOfCentralDirectoryRecord(self, actuallyJustTellMeHowLongItWouldBe
278
278
}
279
279
}
280
280
281
- var eocdrBuffer = Buffer . alloc ( END_OF_CENTRAL_DIRECTORY_RECORD_SIZE + self . comment . length ) ;
281
+ var eocdrBuffer = Buffer . allocUnsafe ( END_OF_CENTRAL_DIRECTORY_RECORD_SIZE + self . comment . length ) ;
282
282
// end of central dir signature 4 bytes (0x06054b50)
283
283
eocdrBuffer . writeUInt32LE ( 0x06054b50 , 0 ) ;
284
284
// number of this disk 2 bytes
@@ -302,7 +302,7 @@ function getEndOfCentralDirectoryRecord(self, actuallyJustTellMeHowLongItWouldBe
302
302
303
303
// ZIP64 format
304
304
// ZIP64 End of Central Directory Record
305
- var zip64EocdrBuffer = new Buffer ( ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE ) ;
305
+ var zip64EocdrBuffer = Buffer . allocUnsafe ( ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE ) ;
306
306
// zip64 end of central dir signature 4 bytes (0x06064b50)
307
307
zip64EocdrBuffer . writeUInt32LE ( 0x06064b50 , 0 ) ;
308
308
// size of zip64 end of central directory record 8 bytes
@@ -328,7 +328,7 @@ function getEndOfCentralDirectoryRecord(self, actuallyJustTellMeHowLongItWouldBe
328
328
329
329
330
330
// ZIP64 End of Central Directory Locator
331
- var zip64EocdlBuffer = new Buffer ( ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE ) ;
331
+ var zip64EocdlBuffer = Buffer . allocUnsafe ( ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE ) ;
332
332
// zip64 end of central dir locator signature 4 bytes (0x07064b50)
333
333
zip64EocdlBuffer . writeUInt32LE ( 0x07064b50 , 0 ) ;
334
334
// number of the disk with the start of the zip64 end of central directory 4 bytes
@@ -361,20 +361,17 @@ function validateMetadataPath(metadataPath, isDirectory) {
361
361
return metadataPath ;
362
362
}
363
363
364
- var defaultFileMode = parseInt ( "0100664" , 8 ) ;
365
- var defaultDirectoryMode = parseInt ( "040775" , 8 ) ;
366
-
367
364
// this class is not part of the public API
368
365
function Entry ( metadataPath , isDirectory , options ) {
369
- this . utf8FileName = new Buffer ( metadataPath ) ;
366
+ this . utf8FileName = Buffer . from ( metadataPath ) ;
370
367
if ( this . utf8FileName . length > 0xffff ) throw new Error ( "utf8 file name too long. " + utf8FileName . length + " > " + 0xffff ) ;
371
368
this . isDirectory = isDirectory ;
372
369
this . state = Entry . WAITING_FOR_METADATA ;
373
370
this . setLastModDate ( options . mtime != null ? options . mtime : new Date ( ) ) ;
374
371
if ( options . mode != null ) {
375
372
this . setFileAttributesMode ( options . mode ) ;
376
373
} else {
377
- this . setFileAttributesMode ( isDirectory ? defaultDirectoryMode : defaultFileMode ) ;
374
+ this . setFileAttributesMode ( isDirectory ? 0o40775 : 0o100664 ) ;
378
375
}
379
376
if ( isDirectory ) {
380
377
this . crcAndFileSizeKnown = true ;
@@ -442,7 +439,7 @@ Entry.prototype.getLocalFileHeader = function() {
442
439
uncompressedSize = this . uncompressedSize ;
443
440
}
444
441
445
- var fixedSizeStuff = new Buffer ( LOCAL_FILE_HEADER_FIXED_SIZE ) ;
442
+ var fixedSizeStuff = Buffer . allocUnsafe ( LOCAL_FILE_HEADER_FIXED_SIZE ) ;
446
443
var generalPurposeBitFlag = FILE_NAME_IS_UTF8 ;
447
444
if ( ! this . crcAndFileSizeKnown ) generalPurposeBitFlag |= UNKNOWN_CRC32_AND_FILE_SIZES ;
448
445
@@ -481,10 +478,10 @@ var ZIP64_DATA_DESCRIPTOR_SIZE = 24;
481
478
Entry . prototype . getDataDescriptor = function ( ) {
482
479
if ( this . crcAndFileSizeKnown ) {
483
480
// the Mac Archive Utility requires this not be present unless we set general purpose bit 3
484
- return new Buffer ( 0 ) ;
481
+ return Buffer . allocUnsafe ( 0 ) ;
485
482
}
486
483
if ( ! this . useZip64Format ( ) ) {
487
- var buffer = new Buffer ( DATA_DESCRIPTOR_SIZE ) ;
484
+ var buffer = Buffer . allocUnsafe ( DATA_DESCRIPTOR_SIZE ) ;
488
485
// optional signature (required according to Archive Utility)
489
486
buffer . writeUInt32LE ( 0x08074b50 , 0 ) ;
490
487
// crc-32 4 bytes
@@ -496,7 +493,7 @@ Entry.prototype.getDataDescriptor = function() {
496
493
return buffer ;
497
494
} else {
498
495
// ZIP64 format
499
- var buffer = new Buffer ( ZIP64_DATA_DESCRIPTOR_SIZE ) ;
496
+ var buffer = Buffer . allocUnsafe ( ZIP64_DATA_DESCRIPTOR_SIZE ) ;
500
497
// optional signature (unknown if anyone cares about this)
501
498
buffer . writeUInt32LE ( 0x08074b50 , 0 ) ;
502
499
// crc-32 4 bytes
@@ -511,7 +508,7 @@ Entry.prototype.getDataDescriptor = function() {
511
508
var CENTRAL_DIRECTORY_RECORD_FIXED_SIZE = 46 ;
512
509
var ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE = 28 ;
513
510
Entry . prototype . getCentralDirectoryRecord = function ( ) {
514
- var fixedSizeStuff = new Buffer ( CENTRAL_DIRECTORY_RECORD_FIXED_SIZE ) ;
511
+ var fixedSizeStuff = Buffer . allocUnsafe ( CENTRAL_DIRECTORY_RECORD_FIXED_SIZE ) ;
515
512
var generalPurposeBitFlag = FILE_NAME_IS_UTF8 ;
516
513
if ( ! this . crcAndFileSizeKnown ) generalPurposeBitFlag |= UNKNOWN_CRC32_AND_FILE_SIZES ;
517
514
@@ -527,7 +524,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
527
524
versionNeededToExtract = VERSION_NEEDED_TO_EXTRACT_ZIP64 ;
528
525
529
526
// ZIP64 extended information extra field
530
- zeiefBuffer = new Buffer ( ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE ) ;
527
+ zeiefBuffer = Buffer . allocUnsafe ( ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE ) ;
531
528
// 0x0001 2 bytes Tag for this "extra" block type
532
529
zeiefBuffer . writeUInt16LE ( 0x0001 , 0 ) ;
533
530
// Size 2 bytes Size of this "extra" block
@@ -542,7 +539,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
542
539
// (omit)
543
540
} else {
544
541
versionNeededToExtract = VERSION_NEEDED_TO_EXTRACT_UTF8 ;
545
- zeiefBuffer = new Buffer ( 0 ) ;
542
+ zeiefBuffer = Buffer . allocUnsafe ( 0 ) ;
546
543
}
547
544
548
545
// central file header signature 4 bytes (0x02014b50)
0 commit comments