summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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