Skip to content

Commit

Permalink
Make status helpers swallow errors
Browse files Browse the repository at this point in the history
It generally isn't helpful for functions like exists to throw an error
if the file doesn't exist.
  • Loading branch information
ShadowNinja committed Oct 7, 2017
1 parent 5d1d058 commit 052187a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/cpfs.cpp
Expand Up @@ -193,9 +193,10 @@ std::chrono::system_clock::time_point Status::ctime() const { return GET_STAT_TI
{ \
return status(path, ec).cond; \
} \
bool func_name(const Path &path) \
bool func_name(const Path &path) noexcept \
{ \
return status(path).cond; \
std::error_code ec; \
return status(path, ec).cond; \
}

STATUS_WRAPPER(exists, type() != FileType::NotFound)
Expand Down
6 changes: 3 additions & 3 deletions src/cpfs.hpp
Expand Up @@ -200,15 +200,15 @@ Status status(const Path &path);

// Checks if the path exists.
bool exists(const Path &path, std::error_code &ec) noexcept;
bool exists(const Path &path);
bool exists(const Path &path) noexcept;

// Checks if the paths points to an existing regular file.
bool is_file(const Path &path, std::error_code &ec) noexcept;
bool is_file(const Path &path);
bool is_file(const Path &path) noexcept;

// Checks if the path points to an existing directory.
bool is_directory(const Path &path, std::error_code &ec) noexcept;
bool is_directory(const Path &path);
bool is_directory(const Path &path) noexcept;


// Attempts to creates a directory at the specified path.
Expand Down

0 comments on commit 052187a

Please sign in to comment.