summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-07-09 18:17:41 +0200
committerMax Kellermann <max@musicpd.org>2019-12-04 12:33:33 +0100
commit75a592f6292114d4d46380d426b53c7b639f24c6 (patch)
treee7bfbb8e5bdb617ec0c5d80408deccf6bc01d6fd /src
parent13ce07d181b1ffa8f73ba9734cbc7d72baaaec91 (diff)
system/Error: move code to IsErrno()
Diffstat (limited to 'src')
-rw-r--r--src/system/Error.hxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/system/Error.hxx b/src/system/Error.hxx
index a94678872..92c638f4f 100644
--- a/src/system/Error.hxx
+++ b/src/system/Error.hxx
@@ -148,6 +148,14 @@ FormatErrno(const char *fmt, Args&&... args) noexcept
}
gcc_pure
+inline bool
+IsErrno(const std::system_error &e, int code) noexcept
+{
+ return e.code().category() == ErrnoCategory() &&
+ e.code().value() == code;
+}
+
+gcc_pure
static inline bool
IsFileNotFound(const std::system_error &e) noexcept
{
@@ -155,8 +163,7 @@ IsFileNotFound(const std::system_error &e) noexcept
return e.code().category() == std::system_category() &&
e.code().value() == ERROR_FILE_NOT_FOUND;
#else
- return e.code().category() == ErrnoCategory() &&
- e.code().value() == ENOENT;
+ return IsErrno(e, ENOENT);
#endif
}
@@ -168,8 +175,7 @@ IsPathNotFound(const std::system_error &e) noexcept
return e.code().category() == std::system_category() &&
e.code().value() == ERROR_PATH_NOT_FOUND;
#else
- return e.code().category() == ErrnoCategory() &&
- e.code().value() == ENOTDIR;
+ return IsErrno(e, ENOTDIR);
#endif
}
@@ -181,8 +187,7 @@ IsAccessDenied(const std::system_error &e) noexcept
return e.code().category() == std::system_category() &&
e.code().value() == ERROR_ACCESS_DENIED;
#else
- return e.code().category() == ErrnoCategory() &&
- e.code().value() == EACCES;
+ return IsErrno(e, EACCES);
#endif
}