Skip to main content

rec_copy_inefficiently

Function rec_copy_inefficiently 

Source
pub fn rec_copy_inefficiently(
    from: impl AsRef<Path>,
    to: impl AsRef<Path>,
) -> Result<()>
Available on crate feature fs only.
Expand description

(Inefficiently) recursively copy all files in from directory to to directory. Old files in to are NOT removed if no corresponding file exists in from. (If that behavior is desired, call cu::fs::make_dir_empty or cu::fs::remove_contents first)

The implementation is naive, suitable for a quick invocation in your build scripts or something. Find other crates if you are looking for an efficient solution that does not involve cloning the files.

§Behavior

  • to will be created if does not exist.
  • symlinks are not followed (they are copied as-is)

§Will error if:

  • from is not a directory, or to exists and is not a directory
  • there is a path in to that is a directory and not a directory in from, or vice versa