Function fs_extra::dir::copy_with_progress [−][src]
pub fn copy_with_progress<P, Q, F>(
from: P,
to: Q,
options: &CopyOptions,
progress_handler: F
) -> Result<u64> where
P: AsRef<Path>,
Q: AsRef<Path>,
F: FnMut(TransitProcess) -> TransitProcessResult,
Copies the directory contents from one place to another using recursive method, with recept information about process. This function will also copy the permission bits of the original files to destionation files (not for directories).
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- This
frompath is not a directory. - This
fromdirectory does not exist. - Invalid folder name for
fromorto. - The current process does not have the permission rights to access
fromor writeto.
Example
ⓘ
extern crate fs_extra; use fs_extra::dir::copy; let options = CopyOptions::new(); //Initialize default values for CopyOptions let handle = |process_info: TransitProcess| { println!("{}", process_info.total_bytes); fs_extra::dir::TransitProcessResult::ContinueOrAbort } // copy source/dir1 to target/dir1 copy_with_progress("source/dir1", "target/dir1", &options, handle)?;