pub fn start_file_with_extra_data<S>(
        &mut self,
        name: S,
        mut options: FileOptions,
    ) -> ZipResult<u64>
    where
        S: Into<String>,
    {
        if options.permissions.is_none() {
            options.permissions = Some(0o644);
        }
        *options.permissions.as_mut().unwrap() |= 0o100000;
        self.start_entry(name, options, None)?;
        self.writing_to_file = true;
        self.writing_to_extra_field = true;
        Ok(self.files.last().unwrap().data_start)
    }
/// Create a file in the archive and start writing its extra data first.
///
/// Finish writing extra data and start writing file data with [`ZipWriter::end_extra_data`].
/// Optionally, distinguish local from central extra data with
/// [`ZipWriter::end_local_start_central_extra_data`].
///
/// Returns the preliminary starting offset of the file data without any extra data allowing to
/// align the file data by calculating a pad length to be prepended as part of the extra data.
///
/// The data should be written using the [`io::Write`] implementation on this [`ZipWriter`]
///
/// ```
/// use byteorder::{LittleEndian, WriteBytesExt};
/// use zip::{ZipArchive, ZipWriter, result::ZipResult};
/// use zip::{write::FileOptions, CompressionMethod};
/// use std::io::{Write, Cursor};
///
/// # fn main() -> ZipResult<()> {
/// let mut archive = Cursor::new(Vec::new());
///
/// {
///     let mut zip = ZipWriter::new(&mut archive);
///     let options = FileOptions::default()
///         .compression_method(CompressionMethod::Stored);
///
///     zip.start_file_with_extra_data("identical_extra_data.txt", options)?;
///     let extra_data = b"local and central extra data";
///     zip.write_u16::<LittleEndian>(0xbeef)?;
///     zip.write_u16::<LittleEndian>(extra_data.len() as u16)?;
///     zip.write_all(extra_data)?;
///     zip.end_extra_data()?;
///     zip.write_all(b"file data")?;
///
///     let data_start = zip.start_file_with_extra_data("different_extra_data.txt", options)?;
///     let extra_data = b"local extra data";
///     zip.write_u16::<LittleEndian>(0xbeef)?;
///     zip.write_u16::<LittleEndian>(extra_data.len() as u16)?;
///     zip.write_all(extra_data)?;
///     let data_start = data_start as usize + 4 + extra_data.len() + 4;
///     let align = 64;
///     let pad_length = (align - data_start % align) % align;
///     assert_eq!(pad_length, 19);
///     zip.write_u16::<LittleEndian>(0xdead)?;
///     zip.write_u16::<LittleEndian>(pad_length as u16)?;
///     zip.write_all(&vec![0; pad_length])?;
///     let data_start = zip.end_local_start_central_extra_data()?;
///     assert_eq!(data_start as usize % align, 0);
///     let extra_data = b"central extra data";
///     zip.write_u16::<LittleEndian>(0xbeef)?;
///     zip.write_u16::<LittleEndian>(extra_data.len() as u16)?;
///     zip.write_all(extra_data)?;
///     zip.end_extra_data()?;
///     zip.write_all(b"file data")?;
///
///     zip.finish()?;
/// }
///
/// let mut zip = ZipArchive::new(archive)?;
/// assert_eq!(&zip.by_index(0)?.extra_data()[4..], b"local and central extra data");
/// assert_eq!(&zip.by_index(1)?.extra_data()[4..], b"central extra data");
/// # Ok(())
/// # }
/// ```
Create a file in the archive and start writing its extra data first.
Finish writing extra data and start writing file data with [`ZipWriter::end_extra_data`].
Optionally, distinguish local from central extra data with
[`ZipWriter::end_local_start_central_extra_data`].

Returns the preliminary starting offset of the file data without any extra data allowing to
align the file data by calculating a pad length to be prepended as part of the extra data.

The data should be written using the [`io::Write`] implementation on this [`ZipWriter`]


Create a file in the archive and start writing its extra data first . Finish writing extra data and start writing file data with [ ` ZipWriter :: end_extra_data ` ] . Optionally distinguish local from central extra data with [ ` ZipWriter :: end_local_start_central_extra_data ` ] . Returns the preliminary starting offset of the file data without any extra data allowing to align the file data by calculating a pad length to be prepended as part of the extra data . The data should be written using the [ ` io :: Write ` ] implementation on this [ ` ZipWriter ` ]
pub fn start_file_with_extra_data<S>(
        &mut self,
        name: S,
        mut options: FileOptions,
    ) -> ZipResult<u64>
    where
        S: Into<String>,
    {
        if options.permissions.is_none() {
            options.permissions = Some(0o644);
        }
        *options.permissions.as_mut().unwrap() |= 0o100000;
        self.start_entry(name, options, None)?;
        self.writing_to_file = true;
        self.writing_to_extra_field = true;
        Ok(self.files.last().unwrap().data_start)
    }
pub fn start_file_with_extra_data < S > ( & mut self , name : S , mut options : FileOptions , ) -> ZipResult < u64 > where S : Into < String > , { if options . permissions . is_none ( ) { options . permissions = Some ( 0o644 ) ; } * options . permissions . as_mut ( ) . unwrap ( ) |= 0o100000 ; self . start_entry ( name , options , None ) ? ; self . writing_to_file = true ; self . writing_to_extra_field = true ; Ok ( self . files . last ( ) . unwrap ( ) . data_start ) }
Create a file in the archive and start writing its extra data first.
Create a file in the archive and start writing its extra data first .
&mut self
name
S
options
FileOptions
&mut self
name
S
options
FileOptions
fn main() -> zipresult<()> {
let mut archive = Cursor::new(Vec::new()).

{
let mut zip = ZipWriter::new(&mut archive);
let options = FileOptions::default()
.compression_method(CompressionMethod::Stored).

zip.start_file_with_extra_data("identical_extra_data.txt", options)?;
let extra_data = b"local and central extra data";
zip.write_u16::(0xbeef)?;
zip.write_u16::(extra_data.len() as u16)?;
zip.write_all(extra_data)?;
zip.end_extra_data()?;
zip.write_all(b"file data")?.

let data_start = zip.start_file_with_extra_data("different_extra_data.txt", options)?;
let extra_data = b"local extra data";
zip.write_u16::(0xbeef)?;
zip.write_u16::(extra_data.len() as u16)?;
zip.write_all(extra_data)?;
let data_start = data_start as usize + 4 + extra_data.len() + 4;
let align = 64;
let pad_length = (align - data_start % align) % align;
assert_eq!(pad_length, 19);
zip.write_u16::(0xdead)?;
zip.write_u16::(pad_length as u16)?;
zip.write_all(&vec![0; pad_length])?;
let data_start = zip.end_local_start_central_extra_data()?;
assert_eq!(data_start as usize % align, 0);
let extra_data = b"central extra data";
zip.write_u16::(0xbeef)?;
zip.write_u16::(extra_data.len() as u16)?;
zip.write_all(extra_data)?;
zip.end_extra_data()?;
zip.write_all(b"file data")?.



let mut zip = ZipArchive::new(archive)?;
assert_eq!(&zip.by_index(0)?.extra_data()[4..], b"local and central extra data");
assert_eq!(&zip.by_index(1)?.extra_data()[4..], b"central extra data").
let mut archive = Cursor :: new ( Vec :: new () ) . { let mut zip = ZipWriter :: new ( &mut archive ) ; let options = FileOptions :: default () . compression_method ( CompressionMethod :: Stored ) . zip . start_file_with_extra_data ( " identical_extra_data . txt " options ) ? ; let extra_data = b " local and central extra data " ; zip . write_u16 :: ( 0xbeef ) ? ; zip . write_u16 :: ( extra_data . len () as u16 ) ? ; zip . write_all ( extra_data ) ? ; zip . end_extra_data () ? ; zip . write_all ( b " file data " ) ? . let data_start = zip . start_file_with_extra_data ( " different_extra_data . txt " options ) ? ; let extra_data = b " local extra data " ; zip . write_u16 :: ( 0xbeef ) ? ; zip . write_u16 :: ( extra_data . len () as u16 ) ? ; zip . write_all ( extra_data ) ? ; let data_start = data_start as usize + 4 + extra_data . len () + 4 ; let align = 64 ; let pad_length = ( align - data_start % align ) % align ; assert_eq! ( pad_length 19 ) ; zip . write_u16 :: ( 0xdead ) ? ; zip . write_u16 :: ( pad_length as u16 ) ? ; zip . write_all ( &vec! [ 0 ; pad_length ] ) ? ; let data_start = zip . end_local_start_central_extra_data () ? ; assert_eq! ( data_start as usize % align 0 ) ; let extra_data = b " central extra data " ; zip . write_u16 :: ( 0xbeef ) ? ; zip . write_u16 :: ( extra_data . len () as u16 ) ? ; zip . write_all ( extra_data ) ? ; zip . end_extra_data () ? ; zip . write_all ( b " file data " ) ? . let mut zip = ZipArchive :: new ( archive ) ? ; assert_eq! ( &zip . by_index ( 0 ) ? . extra_data () [ 4 .. ] b " local and central extra data " ) ; assert_eq! ( &zip . by_index ( 1 ) ? . extra_data () [ 4 .. ] b " central extra data " ) .
ok(())
None
}
None