aboutsummaryrefslogtreecommitdiff
path: root/include/wanda/magic.hpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2022-09-16 21:36:12 +0200
committerFelix Morgner <felix.morgner@gmail.com>2022-09-16 21:36:12 +0200
commit64922e213ac731279cf3341253e67509adb2dfc8 (patch)
treeddcf4fd5b05ac426ecf032e43e8662c2f9ce0f57 /include/wanda/magic.hpp
parentd22bc7b557d36da41fe88d3188a7cd335c3ccaa0 (diff)
downloadwanda-64922e213ac731279cf3341253e67509adb2dfc8.tar.xz
wanda-64922e213ac731279cf3341253e67509adb2dfc8.zip
wanda: restructure source directory
Diffstat (limited to 'include/wanda/magic.hpp')
-rw-r--r--include/wanda/magic.hpp58
1 files changed, 0 insertions, 58 deletions
diff --git a/include/wanda/magic.hpp b/include/wanda/magic.hpp
deleted file mode 100644
index fcb153e..0000000
--- a/include/wanda/magic.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef WANDA_MAGIC_HPP
-#define WANDA_MAGIC_HPP
-
-#include <magic.h>
-
-#include <filesystem>
-#include <memory>
-#include <string>
-#include <type_traits>
-
-namespace wanda
-{
- struct magic
- {
- struct closer
- {
- auto operator()(magic_t handle) const noexcept -> void
- {
- magic_close(handle);
- }
- };
-
- enum struct mime_type
- {
- unknown,
- image_jpeg,
- image_png,
- };
-
- magic()
- : m_handle{magic_open(MAGIC_MIME_TYPE)}
- {
- magic_load(m_handle.get(), nullptr);
- }
-
- auto type(std::filesystem::path path) -> mime_type
- {
- auto magic_type = std::string{magic_file(m_handle.get(), path.native().c_str())};
-
- if (magic_type == "image/jpeg")
- {
- return mime_type::image_jpeg;
- }
- else if (magic_type == "image/png")
- {
- return mime_type::image_png;
- }
-
- return mime_type::unknown;
- }
-
- private:
- std::unique_ptr<std::remove_pointer_t<magic_t>, closer> m_handle;
- };
-
-} // namespace wanda
-
-#endif \ No newline at end of file