copy function

void copy(
  1. String from,
  2. String to, {
  3. bool overwrite = false,
})

Copies the file from to the path to.

copy("/tmp/fred.text", "/tmp/fred2.text", overwrite=true);

to may be a directory in which case the from filename is used to construct the to files full path.

If to is a file then the file must not exist unless overwrite is set to true.

If to is a directory then the directory must exist.

If from is a symlink we copy the file it links to rather than the symlink. This mimics the behaviour of gnu 'cp' command.

If you need to copy the actualy symlink see symlink.

The default for overwrite is false.

If an error occurs a CopyException is thrown.

Implementation

void copy(String from, String to, {bool overwrite = false}) =>
// ignore: discarded_futures
    waitForEx(core.copy(from, to, overwrite: overwrite));