Section: 15.4 [filesys.ts::fs.op.copy_file] Status: TS Submitter: CH-15 Opened: 2014-01-20 Last modified: 2017-07-30
Priority: Not Prioritized
View all issues with TS status.
Discussion:
Addresses: filesys.ts
Even if to and from are different paths, they may be equivalent.
Specify what happens if (options & copy_options::overwrite_existing) but from and to
resolve to the same file.
[2014-02-09, Beman Dawes: Need advice on this issue:]
What do existing implentations do? Possible resolutions:[2014-02-13 LWG/SG-3 Issaquah: LWG/SG-3 decided to treat equivalence in this case as an error. Beman to provide wording.]
[2014-04-09 Beman provided wording as requested. The Effects were rewritten to increase clarity. Behavior remains unchanged except for treating equivalence as an error.]
[17 Jun 2014 Rapperswil LWG moves to Immediate. Jonathan Wakely will provide editorial changes to improve the presentation of bitmask values.]
Proposed resolution:
Change 15.4 [fs.op.copy_file]:Precondition: At most one constant from each
copy_optionsoption group ([enum.copy_options]) is present inoptions.Effects:
Ifexists(to) &&!(options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing))report a file already exists error as specified in Error reporting (7).
If!exists(to) || (options & copy_options::overwrite_existing) || ((options & copy_options::update_existing) && last_write_time(from) > last_write_time(to)) || !(options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing))copy the contents and attributes of the filefromresolves to the filetoresolves to.Report a file already exists error as specified in Error reporting (7) if:
exists(to)andequivalent(from, to), orexists(to)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
fromresolves to to the filetoresolves to if:
!exists(to), orexists(to)and(options & copy_options::overwrite_existing) != copy_options::none, orexists(to)and(options & copy_options::update_existing) != copy_options::noneandfromis more recent thanto, determined as if by use of thelast_write_timefunction.Otherwise no effects.
Returns:
trueif thefromfile was copied, otherwisefalse. The signature with argumentecreturnfalseif an error occurs.Throws: As specified in Error reporting (7).
Complexity: At most one direct or indirect invocation of
status(to).