fn zip_write(
    path: &Path,
    prefix: &Path,
    buffer: &mut Vec<u8>,
    writer: &mut ZipWriter<BufWriter<File>>,
    options: FileOptions,
) -> Result<()> {
    if !path.exists() {
        return Err(FilesystemError::FileDoesntExist {
            path: path.to_owned(),
        });
    }

    let name = path.strip_prefix(prefix).unwrap().to_str().unwrap();

    if path.is_dir() {
        writer.add_directory(name, options)?;
    } else {
        writer.start_file(name, options)?;

        let mut file = File::open(path)?;
        file.read_to_end(buffer)?;

        writer.write_all(buffer)?;
        buffer.clear();
    }

    Ok(())
}
/// Write each path to the zip archive
Write each path to the zip archive
Write each path to the zip archive
fn zip_write(
    path: &Path,
    prefix: &Path,
    buffer: &mut Vec<u8>,
    writer: &mut ZipWriter<BufWriter<File>>,
    options: FileOptions,
) -> Result<()> {
    if !path.exists() {
        return Err(FilesystemError::FileDoesntExist {
            path: path.to_owned(),
        });
    }
    let name = path.strip_prefix(prefix).unwrap().to_str().unwrap();
    if path.is_dir() {
        writer.add_directory(name, options)?;
    } else {
        writer.start_file(name, options)?;
        let mut file = File::open(path)?;
        file.read_to_end(buffer)?;
        writer.write_all(buffer)?;
        buffer.clear();
    }
    Ok(())
}
fn zip_write ( path : & Path , prefix : & Path , buffer : & mut Vec < u8 > , writer : & mut ZipWriter < BufWriter < File > > , options : FileOptions , ) -> Result < ( ) > { if ! path . exists ( ) { return Err ( FilesystemError :: FileDoesntExist { path : path . to_owned ( ) , } ) ; } let name = path . strip_prefix ( prefix ) . unwrap ( ) . to_str ( ) . unwrap ( ) ; if path . is_dir ( ) { writer . add_directory ( name , options ) ? ; } else { writer . start_file ( name , options ) ? ; let mut file = File :: open ( path ) ? ; file . read_to_end ( buffer ) ? ; writer . write_all ( buffer ) ? ; buffer . clear ( ) ; } Ok ( ( ) ) }
Write each path to the zip archive
Write each path to the zip archive
path
&Path
prefix
&Path
buffer
&mut Vec<u8>
writer
&mut ZipWriter<BufWriter<File>>
options
FileOptions
path
&Path
prefix
&Path
buffer
&mut Vec<u8>
writer
&mut ZipWriter<BufWriter<File>>
options
FileOptions