/// Copy one file to a new location, changing metadata.
///
/// # Parameters
///
/// _from_ must exist as a non-directory.
/// _to_ must be a non-existent file, whose parent directory exists.
///
/// # Errors
///
/// If the copy system call fails, we print a verbose error and return an empty error value.
///
Copy one file to a new location, changing metadata.
Copy one file to a new location changing metadata .
fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
    let io_result = fs::copy(from, to);
    if let Err(err) = io_result {
        show_error!(
            "install: cannot install ‘{}’ to ‘{}’: {}",
            from.display(),
            to.display(),
            err
        );
        return Err(());
    }
    if mode::chmod(&to, b.mode()).is_err() {
        return Err(());
    }
    if b.verbose {
        show_info!("'{}' -> '{}'", from.display(), to.display());
    }
    Ok(())
}
fn copy ( from : & PathBuf , to : & PathBuf , b : & Behavior ) -> Result < ( ) , ( ) > { let io_result = fs :: copy ( from , to ) ; if let Err ( err ) = io_result { show_error ! ( " from display ( ) to display ( ) err ) ; return Err ( ( ) ) ; } if mode :: chmod ( & to , b . mode ( ) ) . is_err ( ) { return Err ( ( ) ) ; } if b . verbose { show_info ! ( " " from display ( ) to display ( ) ) ; } Ok ( ( ) ) }
Copy one file to a new location, changing metadata.
Copy one file to a new location changing metadata .
from
&PathBuf
to
&PathBuf
b
&Behavior
errors
If the copy system call fails, we print a verbose error and return an empty error value.
If the copy system call fails we print a verbose error and return an empty error value .