File.copy
You're seeing just the function
copy
, go back to File module for more information.
Specs
copy(Path.t() | io_device(), Path.t() | io_device(), pos_integer() | :infinity) :: {:ok, non_neg_integer()} | {:error, posix()}
Copies the contents of source
to destination
.
Both parameters can be a filename or an IO device opened
with open/2
. bytes_count
specifies the number of
bytes to copy, the default being :infinity
.
If file destination
already exists, it is overwritten
by the contents in source
.
Returns {:ok, bytes_copied}
if successful,
{:error, reason}
otherwise.
Compared to the cp/3
, this function is more low-level,
allowing a copy from device to device limited by a number of
bytes. On the other hand, cp/3
performs more extensive
checks on both source and destination and it also preserves
the file mode after copy.
Typical error reasons are the same as in open/2
,
read/1
and write/3
.