@@ -182,6 +182,7 @@ pub(crate) mod zip_writer {
182182 pub ( super ) zip64_comment : Option < Box < [ u8 ] > > ,
183183 pub ( super ) flush_on_finish_file : bool ,
184184 pub ( super ) seek_possible : bool ,
185+ pub ( crate ) auto_large_file : bool ,
185186 }
186187
187188 impl < W : Write + Seek > Debug for ZipWriter < W > {
@@ -395,10 +396,9 @@ impl<T: FileOptionExtension> FileOptions<'_, T> {
395396
396397 /// Set the compression method for the new file
397398 ///
398- /// The default is `CompressionMethod::Deflated` if it is enabled. If not,
399- /// `CompressionMethod::Bzip2` is the default if it is enabled. If neither `bzip2` nor `deflate`
400- /// is enabled, `CompressionMethod::Zlib` is the default. If all else fails,
401- /// `CompressionMethod::Stored` becomes the default and files are written uncompressed.
399+ /// The default is [`CompressionMethod::Deflated`] if it is enabled. If not,
400+ /// [`CompressionMethod::Bzip2`] is the default if it is enabled. If neither `bzip2` nor `deflate`
401+ /// is enabled, [`CompressionMethod::Stored`] becomes the default and files are written uncompressed.
402402 #[ must_use]
403403 pub const fn compression_method ( mut self , method : CompressionMethod ) -> Self {
404404 self . compression_method = method;
@@ -522,6 +522,28 @@ impl FileOptions<'_, ExtendedFileOptions> {
522522 self
523523 }
524524}
525+ impl FileOptions < ' static , ( ) > {
526+ /// Constructs a const FileOptions object.
527+ ///
528+ /// Note: This value is different than the return value of [`FileOptions::default()`]:
529+ ///
530+ /// - The `last_modified_time` is [`DateTime::DEFAULT`]. This corresponds to 1980-01-01 00:00:00
531+ pub const DEFAULT : Self = Self {
532+ compression_method : CompressionMethod :: DEFAULT ,
533+ compression_level : None ,
534+ last_modified_time : DateTime :: DEFAULT ,
535+ large_file : false ,
536+ permissions : None ,
537+ encrypt_with : None ,
538+ extended_options : ( ) ,
539+ alignment : 1 ,
540+ #[ cfg( feature = "deflate-zopfli" ) ]
541+ zopfli_buffer_size : Some ( 1 << 15 ) ,
542+ #[ cfg( feature = "aes-crypto" ) ]
543+ aes_mode : None ,
544+ } ;
545+ }
546+
525547impl < T : FileOptionExtension > Default for FileOptions < ' _ , T > {
526548 /// Construct a new FileOptions object
527549 fn default ( ) -> Self {
@@ -614,6 +636,7 @@ impl<A: Read + Write + Seek> ZipWriter<A> {
614636 writing_raw : true , // avoid recomputing the last file's header
615637 flush_on_finish_file : false ,
616638 seek_possible : true ,
639+ auto_large_file : false ,
617640 } )
618641 }
619642
@@ -772,9 +795,16 @@ impl<W: Write + Seek> ZipWriter<W> {
772795 zip64_comment : None ,
773796 flush_on_finish_file : false ,
774797 seek_possible : true ,
798+ auto_large_file : false ,
775799 }
776800 }
777801
802+ /// Set automatically large file to true if needed
803+ pub fn set_auto_large_file ( mut self ) -> Self {
804+ self . auto_large_file = true ;
805+ self
806+ }
807+
778808 /// Returns true if a file is currently open for writing.
779809 pub const fn is_writing_file ( & self ) -> bool {
780810 self . writing_to_file && !self . inner . is_closed ( )
@@ -1075,7 +1105,7 @@ impl<W: Write + Seek> ZipWriter<W> {
10751105 } ;
10761106 update_aes_extra_data ( writer, file) ?;
10771107 if file. using_data_descriptor {
1078- file. write_data_descriptor ( writer) ?;
1108+ file. write_data_descriptor ( writer, self . auto_large_file ) ?;
10791109 } else {
10801110 update_local_file_header ( writer, file) ?;
10811111 writer. seek ( SeekFrom :: Start ( file_end) ) ?;
@@ -1622,6 +1652,7 @@ impl<W: Write> ZipWriter<StreamWriter<W>> {
16221652 zip64_comment : None ,
16231653 flush_on_finish_file : false ,
16241654 seek_possible : false ,
1655+ auto_large_file : false ,
16251656 }
16261657 }
16271658}
0 commit comments