diff --git a/src/zip.cpp b/src/zip.cpp index 8139673..4020145 100644 --- a/src/zip.cpp +++ b/src/zip.cpp @@ -39,6 +39,7 @@ namespace epubgrep::zip using boost::locale::translate; using fmt::format; +using std::cerr; std::vector list(const fs::path &filepath) { @@ -112,8 +113,19 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path) close_file(zipfile, filepath); - throw exception{format(translate("{0:s} not found in {1:s}.").str(), + if (entry_path == "META-INF/container.xml") + { // File is probably not an EPUB. + exception e{format(translate("{0:s} not found in {1:s}.").str(), entry_path, filepath.string())}; + e.code = 1; + throw exception{e}; + } + + cerr << translate("WARNING: ") + << format(translate("{0:s} not found in {1:s}.").str(), entry_path, + filepath.string()) + << '\n'; + return {}; } struct archive *open_file(const fs::path &filepath)