KMimeMagic and text/x-c++
David Faure
faure at kde.org
Sat Jun 17 21:50:40 BST 2006
On Saturday 17 June 2006 17:26, Alexander Dymo wrote:
> I've discovered that mime magic fails to return the correct mime
> type for c++ files
>
> For example,
> KMimeType::mimeType() returns KMimeType::Ptr initialized with 0 pointer
> because previous calls to KMimeMagic::findBufferType return
> "text/x-c++" as a part of KMimeMagicResult.
This must be in trunk then. In 3.x mimeType() would return the default mimetype
(application/octet-stream) when asked for an unknown one. Good thing I changed
that, we can now detect such problems ;-)
> And KMimeTypeFactory::findMimeTypeByName() does not find the right
> KMimeType because we have only "text/x-c++hdr" and "text/x-c++src".
>
> What would be the right way to fix this? Introduce text/x-c++ mimetype
> or fix the magic?
The freedesktop.org shared mimetype database says text/x-c++hdr and
text/x-c++src. So the right fix would be to fix the magic (which, for C++,
is in kmimemagic.cpp and not in the kio/magic file).
But how can we find out if this is a source or a header when parsing a
file without extension or with an unknown extension... To do it right we
could parse it for ifndef/define header protection, but this might be a bit
complex. Otherwise we could maybe simply return text/x-c++src...
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel
mailing list