From ee783c9db27827b736bdfa6d4db2995ff20325d2 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Sat, 3 Aug 2024 14:55:22 +0100 Subject: [PATCH] Add kerFileAccessDisabled error code This can be thrown anywhere a file operation is not permitted because exiv2 has been build with EXV_ENABLE_FILESYSTEM off. (cherry picked from commit 5fb8c65ac2109e961af3ac1a7428655e15d60bee) --- include/exiv2/error.hpp | 1 + src/error.cpp | 1 + src/image.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/exiv2/error.hpp b/include/exiv2/error.hpp index 6b7e18e408..bb72eabcef 100644 --- a/include/exiv2/error.hpp +++ b/include/exiv2/error.hpp @@ -224,6 +224,7 @@ enum class ErrorCode { kerArithmeticOverflow, kerMallocFailed, kerInvalidIconvEncoding, + kerFileAccessDisabled, kerErrorCount, }; diff --git a/src/error.cpp b/src/error.cpp index 135f4730d8..1216788179 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -90,6 +90,7 @@ constexpr std::array errList{ N_("Arithmetic operation overflow"), // kerArithmeticOverflow N_("Memory allocation failed"), // kerMallocFailed N_("Cannot convert text encoding from '%1' to '%2'"), // kerInvalidIconvEncoding + N_("%1: File access disabled in exiv2 build options"), // kerFileOpenFailed %1=path }; static_assert(errList.size() == static_cast(Exiv2::ErrorCode::kerErrorCount), "errList needs to contain a error msg for every ErrorCode defined in error.hpp"); diff --git a/src/image.cpp b/src/image.cpp index 3504956ab3..172a107b57 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -831,7 +831,7 @@ BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, [[maybe_unuse return std::make_unique(path); #else - throw Error(ErrorCode::kerFileOpenFailed, path, "", "file access disabled"); + throw Error(ErrorCode::kerFileAccessDisabled, path); #endif } // ImageFactory::createIo