untrusted:: fs:: copy
pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64>
Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.
This function will overwrite the contents of
Note that if
to both point to the same file, then the file
will likely get truncated by this operation.
On success, the total number of bytes copied is returned and it is equal to
the length of the
to file as reported by
This function currently corresponds to the
open function in Unix
O_CLOEXEC is set for returned file descriptors.
On Windows, this function currently corresponds to
NTFS streams are copied but only the size of the main stream is returned by
this function. On MacOS, this function corresponds to
Note that, this may change in the future.
This function will return an error in the following situations, but is not limited to just these cases:
frompath is not a file.
fromfile does not exist.
- The current process does not have the permission rights to access