[lug] C(++) library to detect file type (a la 'file')
rm at fabula.de
rm at fabula.de
Thu Oct 31 10:29:51 MST 2002
On Thu, Oct 31, 2002 at 10:17:47AM -0700, Scott A. Herod wrote:
> rm at fabula.de wrote:
> > Hello everyone,
> > i'm looking for a (GPL comaptible) library that implements file type
> > detection similar to 'file(1)'. The only stuff i found so far is:
> > - in libgnome (which i'd hate to have to install on a server)
> > - There's an article and software package on freedesktop.org that
> > address the need for a unified 'file magic' database, but that
> > lacks a client program/library to query the database.
> > Any pointers (or &references) would be highly welcome.
> > TIA Ralf Mattes
> Hi Ralf,
> Why not just use file? You could either make a system call,
What doyou mean by 'system call' ? I know of no kernel routine that
does file type guessing. Or are you refering to perl's
'system("file $myfile")' function? That's not really an option since
it spawns a shell which then spawns the 'file(1)'application ...
nothing one would want to do when indexing a largish set of documents ;-)
(currently ~ 100 000 docs).
> or build your own utility from the code for the system command. The magic
> configuration file seems to be the key piece.
Well, yes, i could write a library clone (probably using the libgnome
variant which seems to be "good enough" and doesn't have such long
legalese attached to it-boy it's so nice to just see GPL :-)
But i'd hate to reinvent the wheel (read: i have ton's of other code
to write ...).
More information about the LUG