From 7832816c0d239c1cd7a91daef3f15c8f94197e28 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 4 Jun 2026 19:58:56 +0200 Subject: magic: implement file processing --- cabinet/magic.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cabinet/magic.cpp') diff --git a/cabinet/magic.cpp b/cabinet/magic.cpp index 96e212f..b5c1aaa 100644 --- a/cabinet/magic.cpp +++ b/cabinet/magic.cpp @@ -4,6 +4,8 @@ #include #include +#include +#include #include #include #include @@ -51,6 +53,16 @@ namespace cab return *this; } + auto magic::process(std::filesystem::path path) -> std::expected + { + auto result = ::magic_file(m_cookie, path.native().c_str()); + if (!result) + { + return std::unexpected{std::string{::magic_error(m_cookie)}}; + } + return result; + } + auto swap(magic & lhs, magic & rhs) noexcept -> void { auto temp = std::move(lhs); -- cgit v1.2.3