RFP: shared filetype autodetection library



One of the major and important goals of any filter import/export mechanism is the auto-detection of the actual type of any given file, based on its contained data, extension, or some other mechanism (or combination thereof).

What I'm proposing here is the creation of a shared library akin to the 'file' command. Please gently point out to me if gnomevfs or something similar already does this. If something like gnomevfs already has this, I'd like to propose moving it into its own separate library.

What I'd like to see is a mechanism that, when passed one or more of:

* A file (how we choose to represent this is up in the air and not wholly important- FILE*, byte buffer, GnomeVFSHandle, other)
* A portion of a file's contents (initial 2k or 4k or something similar)
* A
file's extension

We get back some magic data, ideally a mime-type and possibly other extended information.



The filter layer plugins then broadcast/advertise what mime-types they support importing. If we want to get fancy, we can also have them identify what mime-types the support exporting to (application/x-abiword, application/vnd.microsoft.excel, ...). Applications then make intelligent decisions based on the mime-types returned by this library, and map them back to the proper input or export filters.

This code would be useful to all office apps, and even a large majority of non-office ones (eog). The first part involves us getting the initial library in place. AbiWord already has some code similar to what I'm describing here. I'm sure that Gnumeric does too (file.c, get_file_saver_for_mime_type). I see that gnome has a gnome_mime_type_or_default which operates on extensions. This is a good start, but a .doc extension on a text document would return application/vnd.microsoft.doc instead of text/plain. It's certainly a start.

So I'm willing to put some deal of time and effort into this. Who's game?

Dom


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com




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