mime api shortcomings



Hi,

	in gedit we hit some shortcomings of the current gnome-vfs api with
regard to getting mime type for a file/filename.

Basically we need these two functions:

1 - guess_mime_from_filename(), which guesses the mime from just the
filename (the real file may not exist and anyway we don't want to stat()
it). As a usecase think of "gedit foo.c" where foo.c doesn't exist yet
and where we want to be able to guess that's aC file.

2 - guess_mime_type_from_data_and_filename() which guesses the mime type
given a chunk of data *and* the filename, once again without hitting the
disk. The use case here is an mmapped file for which we have the data in
memory and thus we don't want to reread the data a second time.


Note that gnome-vfs already has more than a function which does (1)
however non of these functions are exported to apps, they all seem
private to developers of vfs modules. See
http://bugzilla.gnome.org/show_bug.cgi?id=324185.

As for (2) vfs currently has gnome_vfs_get_mime_type_for_data() however
this uses *only* data, so for our mmapped file it returns text/plain no
matter if it's a C file, a python file or whatever else.


Any thoughts/suggestions on how the api should look and on where to
implement this stuff? We are willing to take a look, but current mime
stuff is a bit of a mess to get oriented in given that it's split across
many files, that lots of functions are deprecated and that many mime
related functions are not in the public api...


Paolo




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]