%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2021-2025. All Rights Reserved.
%%
%% %CopyrightEnd%

[;1m  copy(Source, Destination, ByteCount)[0m

  Copies [;;4mByteCount[0m bytes from [;;4mSource[0m to [;;4mDestination[0m. [;;4mSource[0m
  and [;;4mDestination[0m refer to either filenames or IO devices from,
  for example, [;;4mopen/2[0m.

  Argument [;;4mModes[0m is a list of possible modes, see [;;4mopen/2[0m, and
  defaults to [;;4m[][0m.

  If both [;;4mSource[0m and [;;4mDestination[0m refer to filenames, the files
  are opened with [;;4m[read, binary][0m and [;;4m[write, binary][0m prepended
  to their mode lists, respectively, to optimize the copy.

  If [;;4mSource[0m refers to a filename, it is opened with [;;4mread[0m mode
  prepended to the mode list before the copy, and closed when done.

  If [;;4mDestination[0m refers to a filename, it is opened with [;;4mwrite[0m
  mode prepended to the mode list before the copy, and closed when
  done.

  Returns [;;4m{ok, BytesCopied}[0m, where [;;4mBytesCopied[0m is the number of
  bytes that was copied, which can be less than [;;4mByteCount[0m if end
  of file was encountered on the source. If the operation fails, [;;4m[0m
  [;;4m{error, Reason}[0m is returned.

  Typical error reasons: as for [;;4mopen/2[0m if a file had to be opened,
  and as for [;;4mread/2[0m and [;;4mwrite/2[0m.
