system/Error: move code to IsErrno()
This commit is contained in:
parent
13ce07d181
commit
75a592f629
@ -147,6 +147,14 @@ FormatErrno(const char *fmt, Args&&... args) noexcept
|
||||
return FormatErrno(errno, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user