summaryrefslogtreecommitdiff
path: root/cabinet/magic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cabinet/magic.cpp')
-rw-r--r--cabinet/magic.cpp12
1 files changed, 12 insertions, 0 deletions
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 <cerrno>
#include <expected>
+#include <filesystem>
+#include <string>
#include <string_view>
#include <system_error>
#include <utility>
@@ -51,6 +53,16 @@ namespace cab
return *this;
}
+ auto magic::process(std::filesystem::path path) -> std::expected<std::string, std::string>
+ {
+ 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);