summaryrefslogtreecommitdiff
path: root/cabinet/magic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cabinet/magic.cpp')
-rw-r--r--cabinet/magic.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/cabinet/magic.cpp b/cabinet/magic.cpp
index 96b78a3..3c36881 100644
--- a/cabinet/magic.cpp
+++ b/cabinet/magic.cpp
@@ -3,8 +3,10 @@
#include <magic.h>
#include <cerrno>
+#include <cstddef>
#include <expected>
#include <filesystem>
+#include <span>
#include <string>
#include <string_view>
#include <system_error>
@@ -68,6 +70,11 @@ namespace cab
return handle_result(::magic_descriptor(m_cookie, file_descriptor));
}
+ auto magic::process(std::span<std::byte> data) -> std::expected<std::string, std::error_code>
+ {
+ return handle_result(::magic_buffer(m_cookie, data.data(), data.size_bytes()));
+ }
+
auto magic::handle_result(char const * result) -> std::expected<std::string, std::error_code>
{
auto errno_copy = errno;