[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    mimetype determination (Re: KFile plugins)
From:       David Faure <faure () kde ! org>
Date:       2005-10-17 8:49:26
Message-ID: 200510171049.26654.faure () kde ! org
[Download RAW message or body]

On Sunday 16 October 2005 18:46, Thomas Kadauke wrote:
> Am Sunday 16 October 2005 17:38 schrieb Egon Willighagen:
> > What if some other program uses this extension too? I don't know other mime
> > types that use *.h, but have seen other clashes... (think of .log)
> >
> > extension -> mime type is not the option KDE (4.0) should aim at... IMHO
> 
> I agree. Guessing the file type from content won't be a problem

I don't agree, and it would be a problem. Why? Because it's not 100% reliable.
You can't reliably detect the mimetype of files from their content; been there, done that.
E.g. a file with "class, final, static" in it could either be C++ or Java or just some
english text which happens to use those words.
When an extension is specified in the mimetype definition, it *has* priority.
For mimetypes where the extension is ambiguous, then OK, just remove the
mimetype definition and add magic snippets.

To answer the other (mostly wrong) things said in this thread:

* yes the mime-magic mechanism is used in KDE already, for files without
extension or files with an "unknown" extension (i.e. one not listed in Patterns=)

* yes the mime-magic mechanism is extensible, just drop a .magic file
in share/config/magic/.  However this has its limits, it can't be a specialization
of a pattern that is listed in the main magic file (so e.g. it wouldn't work for
koffice files, since they are ZIP files; order matters, so the zip magic is found first).

* for KDE4 the plan is to switch to freedesktop.org mimetype standard,
which includes a way to define "magic" sniffing from within the mimetype
definition itself; and a way to define priority between extension and magic
for a given mimetype.

-- 
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic