From 08754e6ce7812020f38bacf28747d6bcb670fb6e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Dec 2015 12:56:23 +0100 Subject: [PATCH] system/Error: add IsAccessDenied() --- src/system/Error.hxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/system/Error.hxx b/src/system/Error.hxx index 7f862a0ee..5e2ff3bae 100644 --- a/src/system/Error.hxx +++ b/src/system/Error.hxx @@ -138,4 +138,17 @@ IsFileNotFound(const std::system_error &e) #endif } +gcc_pure +static inline bool +IsAccessDenied(const std::system_error &e) +{ +#ifdef WIN32 + return e.code().category() == std::system_category() && + e.code().value() == ERROR_ACCESS_DENIED; +#else + return e.code().category() == std::system_category() && + e.code().value() == EACCES; +#endif +} + #endif