ZMime: a mime/file type detection library

Hi there,

I decided to learn Zig a couple of weeks ago and realized my starting project required identifying file types (in particular, if a file is a text/binary file). I found some libraries around (including libmagic) but could not find anything written purely in Zig (probably because I didn’t search well enough). So, I wrote zmime (GitHub - avac74/zmime: A dependency‑free file type detection library written in Zig.)

This is pretty much my first (real) project with Zig. Any suggestions to improve functionality and to make the code more idiomatic are very much welcomed!

Thanks!

4 Likes

This is fantastic! I was looking at using libmagic for my project a few days ago but shelved it since I didn’t wanna deal with translateC at the time. Will for sure try it out once I have some time.

currently, 42 out of 85 tests from the file repository fail to produce the same mime results as the ones produce by file itself

Half is a quite respectable start. Cool project, I look forward to seeing where you take it.