std::experimental::filesystem::exists

From cppreference.com
< cpp‎ | experimental‎ | fs
Defined in header <experimental/filesystem>
bool exists( file_status s ) noexcept;
(1) (filesystem TS)
bool exists( const path& p );
(2) (filesystem TS)
bool exists( const path& p, error_code& ec ) noexcept;
(3) (filesystem TS)

Checks if the given file status or path corresponds to an existing file or directory.

1) Equivalent to status_known(s) && s.type() != file_type::not_found.
2) Equivalent to exists(status(p)).
3) Equivalent to exists(status(p, ec)). Returns false and sets ec to an appropriate error code if an error occurs. Otherwise, ec is cleared with a call to ec.clear().

Contents

[edit] Parameters

s - file status to check
p - path to examine
ec - error code to store the error status to

[edit] Return value

true if the given path or file status corresponds to an existing file or directory, false otherwise.

[edit] Exceptions

1,3)
noexcept specification:  
noexcept
  
2) filesystem_error if an error occurs. The exception object is constructed with p as an argument. The error code is set to an appropriate error code for the error that caused the failure.

[edit] See also