From ce093be12c4f2c6aab20774b1b4a10cf206b8e35 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Dec 2019 12:31:38 +0100 Subject: [PATCH] system/Error: add FormatFileNotFound() --- src/system/Error.hxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/system/Error.hxx b/src/system/Error.hxx index a22c3ba29..5027e6864 100644 --- a/src/system/Error.hxx +++ b/src/system/Error.hxx @@ -147,6 +147,18 @@ FormatErrno(const char *fmt, Args&&... args) noexcept return FormatErrno(errno, fmt, std::forward(args)...); } +template +static inline std::system_error +FormatFileNotFound(const char *fmt, Args&&... args) noexcept +{ +#ifdef _WIN32 + return FormatLastError(ERROR_FILE_NOT_FOUND, fmt, + std::forward(args)...); +#else + return FormatErrno(ENOENT, fmt, std::forward(args)...); +#endif +} + gcc_pure inline bool IsErrno(const std::system_error &e, int code) noexcept