Questions regarding the shared mime spec
faure at kde.org
Thu Sep 29 08:37:49 PDT 2011
On Monday 26 September 2011 10:07:45 Alexander Larsson wrote:
> The text check should be done in xdg_mime_get_mime_type_for_data, not
> just _xdg_mime_cache_get_mime_type_for_data, in case some directory
> doesn't have a cache file and we fall back on using the "magic" file.
Indeed, I missed a code path.
But if the text check is only done in xdg_mime_get_mime_type_for_data,
then it's missing the case where xdg_mime_cache_get_mime_type_for_file
calls cache_get_mime_type_for_data directly.
This makes it hard to have the check in a single place, I don't see a way
around having the code in two places (or at least a function call in both
... okay after more hacking and testing, the new patch is attached. OK for
commit (to git, this time)? I'll delete the sources from CVS to prevent
further confusion, too.
> Also, our current code in glib doesn't limit itself to the first 32
> chars, but looks at all the data we have read anyway. Is there a
> particular reason to stop early? Performance?
Yes, obviously we don't want to read a 4 GB file, the theory (which is
actually written explicitely in the shared-mime-info spec) is that the chances
of a binary file starting with 32 readable ascii chars is pretty low. I can
see your point in "we have read more than 32 bytes anyway", but then the
results become implementation-dependent, it would depend on how much data was
buffered by a given implementation. So I suggest we use 32 everywhere.
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).
More information about the xdg