mbrubeck / tree_magic

Determines the MIME type of a file by traversing a filetype tree.
MIT License
34 stars 9 forks source link

Detecting different non-plain text (text/*) mime-types. #14

Open m00nwtchr opened 2 years ago

m00nwtchr commented 2 years ago

I can see that this crate is focused on identifying files/arbitrary data by magic values, but afaict this is the only crate which implements the freedesktop shared mime db spec, so it would be nice if from_filepath also checked for matching extensions since most of the work (parsing the db etc.) is already done here, and would have to be duplicated in another crate. Alternatively maybe some of that logic could be split out into another crate which then i could use to implement filename checking?

mbrubeck commented 7 months ago

This could be done using the “globs” files from the Shared MIME-info Database:

https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#idm45617682177472

I don’t have any plans to work on this, but would welcome contributions. For now, the mime_guess crate offers a similar feature.