Small C++ library for mime type identification using file extensions
mime can be installed using Conan
foo@bar:~$ git clone https://github.com/tiger-chan/mime.git
foo@bar:~$ cd mime
foo@bar:~/mime$ mkdir build
foo@bar:~/mime$ cd build && conan create .. mime/[~= 0.1]@tiger-chan/stable
foo@bar:~/your-proj$ conan install mime/[~= 0.1]@tiger-chan/stable
If you handle multiple dependencies in your project is better to add a conanfile.txt
[requires]
mime/[~= 0.1]@tiger-chan/stable
[generators]
txt
Complete the installation of requirements for your project running:
foo@bar:~/your-proj$ mkdir build && cd build && conan install ..
NOTE: It is recommended not to run the install/build commands in the project directory. This is because conan generates many files which are tied to specific build configurations.
To use mime
from a CMake project, just link an existing target to the
mime::mime
alias.
The library offers everything you need for locating (as in find_package
),
embedding (as in add_subdirectory
), or fetching (as in FetchContent
).
The source of truth for the MIME types are read and generated from mime-db. If a type is missing please create a PR there. You can also create a issue here for the library to update list once the Once it has been merged in to mime-db PR has been completed.
NOTE: The method of search relies on file extensions, as such the list is filtered to only those with extensions.
The API can be accessed through the inclusion of a single header (mime.hpp
).
#include <mime/mime.hpp>
The API follows a functional approach for functions.
- No (de)allocations are made by the library.
- All functions will will request that you provide destination (pointer or buffer) for the result.
- There are no instances of of throwing exceptions;
- Because, All functions will provide a state result e.g.,
MIME_SUCCESS
,MIME_NO_MATCH
, etc...
Requests for features, PRs, suggestions and feedback are very welcome.
see CONTRIBUTING for more information.
Code and documentation Copyright (c) 2022 Anthony Young. Code released under MIT