I’m writing a program in C, and I need to known the mime-type of a file.
I have yet searched with Google, and I found that I must include the ‘file’ UNIX utility in my project.
The source code of file need configure and make. How I can include this in my project? Do I have to crop a part of the source code into a new file.c and file.h?
Do you want to guess the MIME type based on the extension, or do something like
fileand examine the headers?To get functionality similar to
file, you don’t need to includefilein your project. Instead, you’ll want to use libmagic whichfileis based on. Unfortunately I’m not aware of a good source of documentation for this, but it’s pretty straightforward.