pub fn next_file(&mut self) -> io::Result<Option<FileWriter<W>>> {
        let num_folders = self.builder.folders.len();
        while self.current_folder_index < num_folders {
            if self.next_file_index > 0 {
                // End previous file:
                let folder = &self.builder.folders[self.current_folder_index];
                let file = &folder.files[self.next_file_index - 1];
                self.offset_within_folder += file.uncompressed_size as u64;
            }
            let num_files =
                self.builder.folders[self.current_folder_index].files.len();
            if self.next_file_index < num_files {
                let folder =
                    &mut self.builder.folders[self.current_folder_index];
                if self.next_file_index == 0 {
                    // Begin folder:
                    match self.writer.take() {
                        InnerCabinetWriter::Raw(writer) => {
                            let folder_writer = FolderWriter::new(
                                writer,
                                folder.compression_type,
                                folder.entry_offset,
                            )?;
                            self.writer =
                                InnerCabinetWriter::Folder(folder_writer);
                        }
                        _ => unreachable!(),
                    }
                }
                // Begin next file:
                let file = &mut folder.files[self.next_file_index];
                if self.offset_within_folder > (u32::MAX as u64) {
                    invalid_data!(
                        "Folder is overfull \
                         (file offset of {} bytes, max is {} bytes)",
                        self.offset_within_folder,
                        u32::MAX
                    );
                }
                file.offset_within_folder = self.offset_within_folder as u32;
                let file_writer = match self.writer {
                    InnerCabinetWriter::Folder(ref mut folder_writer) => {
                        FileWriter::new(folder_writer, file)
                    }
                    _ => unreachable!(),
                };
                self.next_file_index += 1;
                return Ok(Some(file_writer));
            }
            // End folder:
            match self.writer.take() {
                InnerCabinetWriter::Folder(folder_writer) => {
                    let folder =
                        &self.builder.folders[self.current_folder_index];
                    let writer = folder_writer.finish(&folder.files)?;
                    self.writer = InnerCabinetWriter::Raw(writer);
                }
                _ => unreachable!(),
            }
            self.current_folder_index += 1;
            self.next_file_index = 0;
            self.offset_within_folder = 0;
        }
        Ok(None)
    }
/// Returns a `FileWriter` for the next file within that cabinet that needs
/// data to be written, or `None` if all files are now complete.
Returns a `FileWriter` for the next file within that cabinet that needs
data to be written, or `None` if all files are now complete.
Returns a ` FileWriter ` for the next file within that cabinet that needs data to be written or ` None ` if all files are now complete .
pub fn next_file(&mut self) -> io::Result<Option<FileWriter<W>>> {
        let num_folders = self.builder.folders.len();
        while self.current_folder_index < num_folders {
            if self.next_file_index > 0 {
                // End previous file:
                let folder = &self.builder.folders[self.current_folder_index];
                let file = &folder.files[self.next_file_index - 1];
                self.offset_within_folder += file.uncompressed_size as u64;
            }
            let num_files =
                self.builder.folders[self.current_folder_index].files.len();
            if self.next_file_index < num_files {
                let folder =
                    &mut self.builder.folders[self.current_folder_index];
                if self.next_file_index == 0 {
                    // Begin folder:
                    match self.writer.take() {
                        InnerCabinetWriter::Raw(writer) => {
                            let folder_writer = FolderWriter::new(
                                writer,
                                folder.compression_type,
                                folder.entry_offset,
                            )?;
                            self.writer =
                                InnerCabinetWriter::Folder(folder_writer);
                        }
                        _ => unreachable!(),
                    }
                }
                // Begin next file:
                let file = &mut folder.files[self.next_file_index];
                if self.offset_within_folder > (u32::MAX as u64) {
                    invalid_data!(
                        "Folder is overfull \
                         (file offset of {} bytes, max is {} bytes)",
                        self.offset_within_folder,
                        u32::MAX
                    );
                }
                file.offset_within_folder = self.offset_within_folder as u32;
                let file_writer = match self.writer {
                    InnerCabinetWriter::Folder(ref mut folder_writer) => {
                        FileWriter::new(folder_writer, file)
                    }
                    _ => unreachable!(),
                };
                self.next_file_index += 1;
                return Ok(Some(file_writer));
            }
            // End folder:
            match self.writer.take() {
                InnerCabinetWriter::Folder(folder_writer) => {
                    let folder =
                        &self.builder.folders[self.current_folder_index];
                    let writer = folder_writer.finish(&folder.files)?;
                    self.writer = InnerCabinetWriter::Raw(writer);
                }
                _ => unreachable!(),
            }
            self.current_folder_index += 1;
            self.next_file_index = 0;
            self.offset_within_folder = 0;
        }
        Ok(None)
    }
pub fn next_file ( & mut self ) -> io :: Result < Option < FileWriter < W > > > { let num_folders = self . builder . folders . len ( ) ; while self . current_folder_index < num_folders { if self . next_file_index > 0 { // End previous file: let folder = & self . builder . folders [ self . current_folder_index ] ; let file = & folder . files [ self . next_file_index - 1 ] ; self . offset_within_folder += file . uncompressed_size as u64 ; } let num_files = self . builder . folders [ self . current_folder_index ] . files . len ( ) ; if self . next_file_index < num_files { let folder = & mut self . builder . folders [ self . current_folder_index ] ; if self . next_file_index == 0 { // Begin folder: match self . writer . take ( ) { InnerCabinetWriter :: Raw ( writer ) => { let folder_writer = FolderWriter :: new ( writer , folder . compression_type , folder . entry_offset , ) ? ; self . writer = InnerCabinetWriter :: Folder ( folder_writer ) ; } _ => unreachable ! ( ) , } } // Begin next file: let file = & mut folder . files [ self . next_file_index ] ; if self . offset_within_folder > ( u32 :: MAX as u64 ) { invalid_data ! ( " \
 " self offset_within_folder u32 MAX ) ; } file . offset_within_folder = self . offset_within_folder as u32 ; let file_writer = match self . writer { InnerCabinetWriter :: Folder ( ref mut folder_writer ) => { FileWriter :: new ( folder_writer , file ) } _ => unreachable ! ( ) , } ; self . next_file_index += 1 ; return Ok ( Some ( file_writer ) ) ; } // End folder: match self . writer . take ( ) { InnerCabinetWriter :: Folder ( folder_writer ) => { let folder = & self . builder . folders [ self . current_folder_index ] ; let writer = folder_writer . finish ( & folder . files ) ? ; self . writer = InnerCabinetWriter :: Raw ( writer ) ; } _ => unreachable ! ( ) , } self . current_folder_index += 1 ; self . next_file_index = 0 ; self . offset_within_folder = 0 ; } Ok ( None ) }
Returns a `FileWriter` for the next file within that cabinet that needs
data to be written, or `None` if all files are now complete.
Returns a ` FileWriter ` for the next file within that cabinet that needs data to be written or ` None ` if all files are now complete .
&mut self
&mut self