File.cp
cp, go back to File module for more information.
cp(source_file, destination_file, callback \\ fn _, _ -> true end)
View SourceSpecs
Copies the contents of source_file to destination_file preserving its modes.
source_file must be a file or a symbolic link to one. destination_file must
be a path to a non-existent file. If either is a directory, {:error, :eisdir}
will be returned.
The callback function is invoked if the destination_file already exists.
The function receives arguments for source_file and destination_file;
it should return true if the existing file should be overwritten, false if
otherwise. The default callback returns true.
The function returns :ok in case of success. Otherwise, it returns
{:error, reason}.
If you want to copy contents from an IO device to another device
or do a straight copy from a source to a destination without
preserving modes, check copy/3 instead.
Note: The command cp in Unix-like systems behaves differently depending on
whether the destination is an existing directory or not. We have chosen to
explicitly disallow copying to a destination which is a directory,
and an error will be returned if tried.