sys: Cleanup libmagic mess

This commit is contained in:
WerWolv
2021-09-06 16:15:05 +02:00
parent f29febdc86
commit 6879cf765f
8 changed files with 157 additions and 80 deletions

View File

@@ -0,0 +1,23 @@
#pragma once
namespace hex::literals {
/* Byte literals */
unsigned long long operator ""_Bytes(unsigned long long bytes) {
return bytes;
}
unsigned long long operator ""_kiB(unsigned long long kiB) {
return operator ""_Bytes(kiB * 1024);
}
unsigned long long operator ""_MiB(unsigned long long MiB) {
return operator ""_kiB(MiB * 1024);
}
unsigned long long operator ""_GiB(unsigned long long GiB) {
return operator ""_MiB(GiB * 1024);
}
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include <hex.hpp>
#include <hex/helpers/literals.hpp>
#include <string>
#include <vector>
namespace hex::prv { class Provider; }
namespace hex::magic {
using namespace hex::literals;
bool compile();
std::string getDescription(const std::vector<u8> &data);
std::string getDescription(prv::Provider *provider, size_t size = 5_MiB);
std::string getMIMEType(const std::vector<u8> &data);
std::string getMIMEType(prv::Provider *provider, size_t size = 5_MiB);
}