1
0
Fork
You've already forked libzmime
0
Get MIME type of a file with libmagic
  • Zig 87.8%
  • C 12.2%
2026年06月25日 10:35:38 +05:30
src [dev] Initial Implementation of getMIME 2026年06月23日 19:55:53 +05:30
.clang-format [style] Added .clang-format 2026年06月23日 18:39:10 +05:30
.gitignore [dev] Hello World 2026年06月23日 18:37:57 +05:30
build.zig [dev] Initial Implementation of getMIME 2026年06月23日 19:55:53 +05:30
build.zig.zon [build] Version bump 2026年06月25日 10:35:38 +05:30
LICENSE [LICENSE] MIT 2026年06月23日 23:05:51 +05:30
README.md [docs] Update URL 2026年06月24日 18:46:20 +05:30

LibZMIME


A simple wrapper around libmagic and exposes a single function getMIME, which gives the MIME Type of a file.

As with all projects, new features will be added when I need them :)

Dependencies

I hate it, but here are the dependencies that you need

  • Debian/Ubuntu
apt install libmagic-dev

Installing

To use this library in your project just do

Min Zig Version 0.16.0

Getting LibZMIME

zig fetch --save git+https://codeberg.org/Adwaith-Rajesh/libzmime.git

Build.Zig

constzmime_dep=b.dependency("libzmime",.{.target=target,.optimize=optimize,});

Usage

conststd=@import("std");constzmime=@import("zmime");pubfnmain(init:std.process.Init)!void{constio=init.io;// we are writing to stdout in this examplevarstdout_buf:[1024]u8=undefined;varstdout_writer=std.Io.File.stdout().writer(io,&stdout_buf);constsw=&stdout_writer.interface;tryzmime.getMIME(sw,"filename");trysw.writeByte('\n');trysw.flush();}
Output

If the file is a plain text file

text/plain

If you have any issue, please create an issue in the Issue Tracker or join the Discord Server

Byeee...