Function fs_extra::file::copy [−][src]
pub fn copy<P, Q>(from: P, to: Q, options: &CopyOptions) -> Result<u64> where
P: AsRef<Path>,
Q: AsRef<Path>,
Copies the contents of one file to another. 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 rights to access
from
or writeto
.
Example
ⓘ
extern crate fs_extra; use fs_extra::file::copy; let options = CopyOptions::new(); //Initialize default values for CopyOptions copy("dir1/foo.txt", "dir2/bar.txt", &options)?; // Copy dir1/foo.txt to dir2/bar.txt