Title
filesystem::exists(const path&, error_code&) error reporting
Status
c++17
Section
[fs.op.exists]
Submitter
Jonathan Wakely

Created on 2016-06-06.00:00:00 last changed 89 months ago

Messages

Date: 2016-06-27.16:44:20

Proposed resolution:

This wording is relative to N4594.

  1. Insert a new paragraph before [fs.op.exists] p2 and edit it as shown:

    bool exists(const path& p);
    bool exists(const path& p, error_code& ec) noexcept;
    

    -?- Let s be a file_status, determined as if by status(p) or status(p, ec), respectively.

    -?- Effects: The signature with argument ec calls ec.clear() if status_known(s).

    -2- Returns: exists(status(p)) or exists(status(p, ec)), respectivelyexists(s). The signature with argument ec returns false if an error occurs.

Date: 2016-06-27.16:44:20

[ 2016-06, Oulu ]

Prioritized as P1

Voted to Ready 7-0 Tuesday evening in Oulu

Date: 2016-06-20.15:57:37

[ 2016-06, Oulu — Jonathan comments and provides wording ]

The sentence "The signature with argument ec returns false if an error occurs." means that given a file such that status(p).type() == file_type::unknown, exists(p) is true but exists(p, ec) is false.

I believe we should make the behaviour of exists(p) and exists(p, ec) consistent, so that the latter clears ec except when the former would throw an exception, which is only for the file_type::none case.

Date: 2016-06-06.00:00:00

The filesystem::exists(const path&) function does not throw an exception if the file doesn't exist, but the corresponding function taking an error_code& argument does set it to indicate an error.

It seems sensible for filesystem::exists(const path&, error_code&) to call ec.clear() if status(p, ec).type() == file_type::not_found.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-06-28 12:55:35adminsetstatus: immediate -> wp
2016-06-27 16:44:20adminsetmessages: + msg8210
2016-06-27 16:44:20adminsetstatus: new -> immediate
2016-06-20 15:57:37adminsetmessages: + msg8181
2016-06-20 15:57:37adminsetmessages: + msg8180
2016-06-06 00:00:00admincreate