Re: file(1) / magic(5) database vs shared-mime-info database

Kip Warner <[email protected]>
Newsgroups gmane.linux.xdg.devel
Message-ID <[email protected]>
On Sat, 2018-02-24 at 14:17 +0100, Bastien Nocera wrote:
> No, it wouldn't make sense. They have very different use cases and
> restrictions. In shared-mime-info:
> - mime-types don't have to have a magic associated

True, but I believe file(1)'s magic(5) database doesn't need to either.
It can "detect" a MIME type based on just a file extension if that's
what the rule writer provided.

> - and mime-types have globs associated
> - the magic length is limited to avoid seeking through huge files

The magic(5) can also handle this by having rules that specify specific
file offsets to check.

> - descriptions are translated, acronyms can be split-off and expanded

Yes, that's a good point.

> - mime-types have inheritance

Another good point.

> There's probably others, but that's already a good chunk of the
> problems we'd encounter if we used file's database.

One capability file(1)'s magic(5) method has that nobody has mentioned
is the ability to identify not only the MIME type, but also a more
descriptive comment on the file's contents. As an example, consider the
magic I wrote to detect Maxis Database Packed Files.

    https://github.com/file/file/blob/master/magic/Magdir/dbpf

If I just want to know the MIME type:

    $ file --mime-type SimCity_Audio_Banks.package
    SimCity_Audio_Banks.package: application/x-maxis-dbpf

But if I want to see a more descriptive comment:

    $ file SimCity_Audio_Banks.package
    SimCity_Audio_Banks.package: Maxis Database Packed File, version: 3.0, files: 83

I think what I've started to figure out is file(1) / magic(5) are meant
to be used directly by users as well as the API for magic(5) by other
applications. In the case of shared-mime-info it's designed to be used
primarily by other applications. It's rare users try to identify a file
 by 'gio info foo'.

That might make these two mechanisms justify their own distinct
existence, but something that I think should be done at the least is
consolidate the redundant magic itself.

-- 
Kip Warner | Senior Software Engineer
OpenPGP signed/encrypted mail preferred
https://www.cartesiantheatre.com

_______________________________________________
xdg mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/xdg
signature.asc (application/pgp-signature, 163 B)
-----BEGIN PGP SIGNATURE-----

iEYEABECAAYFAlqTNP8ACgkQLXnfK7bii23IswCgvBbDUH23S/VmL5rLjtgL32B5
ELwAoIorwY8bi975pvAhHUEYMm3Cpvi0
=Ftjj
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.