summaryrefslogtreecommitdiff
path: root/cabinet/magic.hpp
blob: 3ad6dface653232f9a5dc7a8eb33ee7eaae5ae1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef CABINET_MAGIC_HPP
#define CABINET_MAGIC_HPP

#include <magic.h>

#include <utility>

namespace cab
{

  struct magic
  {
    enum struct flags : decltype(MAGIC_NONE)
    {
      none = MAGIC_NONE,
      print_debug = MAGIC_DEBUG,
      follow_symlinks = MAGIC_SYMLINK,
      inspect_compressed = MAGIC_COMPRESS,
      inspect_devices = MAGIC_DEVICES,
    };

    magic(flags flags);
    ~magic();

  private:
    magic_t m_cookie{};
  };

  constexpr auto operator|(magic::flags lhs, magic::flags rhs) noexcept -> magic::flags
  {
    return static_cast<magic::flags>(std::to_underlying(lhs) | std::to_underlying(rhs));
  }

}  // namespace cab

#endif