summaryrefslogtreecommitdiff
path: root/src/system
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-12-18 00:54:08 +0100
committerMax Kellermann <max@duempel.org>2015-12-18 00:54:23 +0100
commit93f45904537e2ca9837051fddf4b2b80587d87bf (patch)
tree7abf7754d254bcc640c13ce29ef1876a78e32b8f /src/system
parent1098d271b8e8207ce901267716c3335e90bfe585 (diff)
system/Error: add IsFileNotFound()
Diffstat (limited to 'src/system')
-rw-r--r--src/system/Error.hxx14
1 files changed, 14 insertions, 0 deletions
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 <system_error>
#include <utility>
@@ -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