pub fn move_file_with_progress<P, Q, F>(
from: P,
to: Q,
options: &CopyOptions,
progress_handler: F,
) -> Result<u64>
Expand description
Moves a file from one place to another with information about progress. This function will also copy the permission bits of the original file to the destination file.
§Errors
This function will return an error in the following situations, but is not limited to just these cases:
- This
from
path is not a file. - This
from
file does not exist. - The current process does not have the permission to access
from
or writeto
.
§Example
ⓘ
extern crate fs_extra;
use fs_extra::file::move_file;
let options = CopyOptions::new(); //Initialize default values for CopyOptions
let handle = |process_info: TransitProcess| println!("{}", process_info.total_bytes);
// Move dir1/foo.txt to dir2/foo.txt
move_file("dir1/foo.txt", "dir2/foo.txt", &options, handle)?;