Files
cppdraft_translate/cppdraft/fs/op/copy/file.md
2025-10-25 03:02:53 +03:00

3.4 KiB
Raw Blame History

[fs.op.copy.file]

31 Input/output library [input.output]

31.12 File systems [filesystems]

31.12.13 Filesystem operation functions [fs.op.funcs]

31.12.13.5 Copy file [fs.op.copy.file]

🔗

bool filesystem::copy_file(const path& from, const path& to); bool filesystem::copy_file(const path& from, const path& to, error_code& ec);

1

#

Returns: copy_file(from, to, copy_options::none) or

copy_file(from, to, copy_options::none, ec), respectively.

2

#

Throws: As specified in [fs.err.report].

🔗

bool filesystem::copy_file(const path& from, const path& to, copy_options options); bool filesystem::copy_file(const path& from, const path& to, copy_options options, error_code& ec);

3

#

Preconditions: At most one element from each option group ([fs.enum.copy.opts]) is set in options.

4

#

Effects: As follows:

is_regular_file(from) is false, or

exists(to) is true and is_regular_file(to) is false, or

exists(to) is true and equivalent(from, to) is true, or

exists(to) is true and(options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing)) == copy_options::none

  • (4.2)

    Otherwise, copy the contents and attributes of the file from resolves to, to the file to resolves to, if

exists(to) is false, or

(options & copy_options::overwrite_existing) != copy_options::none, or

(options & copy_options::update_existing) != copy_options::none and from is more recent than to, determined as if by use of the last_write_time function ([fs.op.last.write.time]).

  • (4.3)

    Otherwise, no effects.

5

#

Returns: true if the from file was copied, otherwise false.

The signature with argument ec returns false if an error occurs.

6

#

Throws: As specified in [fs.err.report].

7

#

Complexity: At most one direct or indirect invocation of status(to).