fn write_image_and_sig(
    source: &mut ImageSource,
    path: &Path,
    sig_path: &Path,
    decompress: bool,
    save_sig: bool,
    keys: VerifyKeys,
) -> Result<()> {
    // open output
    let mut dest = OpenOptions::new()
        .write(true)
        .create(true)
        .truncate(true)
        .open(path)
        .with_context(|| format!("opening {}", path.display()))?;

    // download and verify image
    // don't check sector size
    write_image(
        source,
        &mut dest,
        path,
        image_copy_default,
        decompress,
        None,
        None,
        keys,
    )?;

    // write signature, if requested
    if let (true, Some(signature)) = (save_sig, source.signature.as_ref()) {
        let mut sig_dest = OpenOptions::new()
            .write(true)
            .create(true)
            .truncate(true)
            .open(sig_path)
            .with_context(|| format!("opening {}", sig_path.display()))?;
        sig_dest
            .write_all(signature)
            .context("writing signature data")?;
    }

    Ok(())
}
/// Copy the image to disk, and also the signature if requested.
Copy the image to disk, and also the signature if requested.
Copy the image to disk and also the signature if requested .
fn write_image_and_sig(
    source: &mut ImageSource,
    path: &Path,
    sig_path: &Path,
    decompress: bool,
    save_sig: bool,
    keys: VerifyKeys,
) -> Result<()> {
    // open output
    let mut dest = OpenOptions::new()
        .write(true)
        .create(true)
        .truncate(true)
        .open(path)
        .with_context(|| format!("opening {}", path.display()))?;
    // download and verify image
    // don't check sector size
    write_image(
        source,
        &mut dest,
        path,
        image_copy_default,
        decompress,
        None,
        None,
        keys,
    )?;
    // write signature, if requested
    if let (true, Some(signature)) = (save_sig, source.signature.as_ref()) {
        let mut sig_dest = OpenOptions::new()
            .write(true)
            .create(true)
            .truncate(true)
            .open(sig_path)
            .with_context(|| format!("opening {}", sig_path.display()))?;
        sig_dest
            .write_all(signature)
            .context("writing signature data")?;
    }
    Ok(())
}
fn write_image_and_sig ( source : & mut ImageSource , path : & Path , sig_path : & Path , decompress : bool , save_sig : bool , keys : VerifyKeys , ) -> Result < ( ) > { // open output let mut dest = OpenOptions :: new ( ) . write ( true ) . create ( true ) . truncate ( true ) . open ( path ) . with_context ( | | format ! ( " " path display ( ) ) ) ? ; // download and verify image // don't check sector size write_image ( source , & mut dest , path , image_copy_default , decompress , None , None , keys , ) ? ; // write signature, if requested if let ( true , Some ( signature ) ) = ( save_sig , source . signature . as_ref ( ) ) { let mut sig_dest = OpenOptions :: new ( ) . write ( true ) . create ( true ) . truncate ( true ) . open ( sig_path ) . with_context ( | | format ! ( " " sig_path display ( ) ) ) ? ; sig_dest . write_all ( signature ) . context ( " " ) ? ; } Ok ( ( ) ) }
Copy the image to disk, and also the signature if requested.
Copy the image to disk and also the signature if requested .
source
&mut ImageSource
path
&Path
sig_path
&Path
decompress
bool
save_sig
bool
keys
VerifyKeys
source
&mut ImageSource
path
&Path
sig_path
&Path
decompress
bool
save_sig
bool
keys
VerifyKeys