[fs.op.copy.file] (original) (raw)
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);
Returns: copy_file(from, to, copy_options::none) or
copy_file(from, to, copy_options::none, ec), respectively.
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);
Preconditions: At most one element from each option group ([fs.enum.copy.opts]) is set in options.
Effects: As follows:
- Report an error as specified in [fs.err.report] if
- 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
- 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]).
Returns: true if the from file was copied, otherwise false.
The signature with argument ec returnsfalse if an error occurs.
Complexity: At most one direct or indirect invocation of status(to).