From 93f45904537e2ca9837051fddf4b2b80587d87bf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 18 Dec 2015 00:54:08 +0100 Subject: system/Error: add IsFileNotFound() --- src/system/Error.hxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/system') diff --git a/src/system/Error.hxx b/src/system/Error.hxx index 5f7f4eb59..948bb47e5 100644 --- a/src/system/Error.hxx +++ b/src/system/Error.hxx @@ -31,6 +31,7 @@ #define SYSTEM_ERROR_HXX #include "util/StringUtil.hxx" +#include "Compiler.h" #include #include @@ -106,4 +107,17 @@ FormatErrno(const char *fmt, Args&&... args) #endif +gcc_pure +static inline bool +IsFileNotFound(const std::system_error &e) +{ +#ifdef WIN32 + return e.code().category() == std::system_category() && + e.code().value() == ERROR_FILE_NOT_FOUND; +#else + return e.code().category() == std::system_category() && + e.code().value() == ENOENT; +#endif +} + #endif -- cgit v1.2.3