org.kde.koala

Class KMimeMagic

public class KMimeMagic extends Object implements QtSupport

May be removed in KDE 4.0. Determine auto-magically the type of file, not only by using its extension, but also by reading its contents. Unless specified otherwise, KMimeMagic uses $KDEDIR/share/mimelnk/magic for this purpose. To make KMimeMagic restore the 'atime' of a file after it opened it, add its directory in kmimemagicrc like: [Settings] atimeDirs=/tmp,/var/tmp,/home/dfaure/tmp This isn't done by default because it changes the 'ctime'. See kmimemagic.cpp for a full discussion on this issue. The basic usage of KMimeMagic is :
  • Get a pointer to it, using KMimeMagic.self().
  • Use it for any file or buffer you want, using one of the three find...Type() methods.
  • The result is contained in the class KMimeMagicResult.

    UNKNOWN:

    Constructor Summary
    protected KMimeMagic(Class dummy)
    KMimeMagic()
    Create a parser and initialize it with the KDE-global data: the "magic" config file as well as the snippets from share/config/magic.
    KMimeMagic(String configFile)
    Create a parser and initialize it with the given config file.
    Method Summary
    voiddispose()
    Delete the wrapped C++ instance ahead of finalize()
    protected voidfinalize()
    Deletes the wrapped C++ instance
    KMimeMagicResultfindBufferFileType(byte[] arg1, String filename)
    Same functionality as findBufferType() but with additional capability of distinguishing between C-headers and C-Source.
    KMimeMagicResultfindBufferType(byte[] p)
    Same functionality as above, except data is not read from a file.
    KMimeMagicResultfindFileType(String _filename)
    Try to find a MimeType for the given file.
    protected static voidinitStatic()
    booleanisDisposed()
    Has the wrapped C++ instance been deleted?
    booleanmergeBufConfig(String arg1)
    Merge an existing parse table with the data from the given buffer.
    booleanmergeConfig(String configFile)
    Merge an existing parse table with the data from the given file.
    static KMimeMagicself()
    Returns a pointer to the unique KMimeMagic instance in this process.
    voidsetFollowLinks(boolean _enable)
    Enable/Disable follow-links.

    Constructor Detail

    KMimeMagic

    protected KMimeMagic(Class dummy)

    KMimeMagic

    public KMimeMagic()
    Create a parser and initialize it with the KDE-global data: the "magic" config file as well as the snippets from share/config/magic.

    UNKNOWN: Create a parser and initialize it with the KDE-global data: the "magic" config file as well as the snippets from share/config/magic.

    KMimeMagic

    public KMimeMagic(String configFile)
    Create a parser and initialize it with the given config file.

    UNKNOWN: Create a parser and initialize it with the given config file.

    Method Detail

    dispose

    public void dispose()
    Delete the wrapped C++ instance ahead of finalize()

    finalize

    protected void finalize()
    Deletes the wrapped C++ instance

    findBufferFileType

    public KMimeMagicResult findBufferFileType(byte[] arg1, String filename)
    Same functionality as findBufferType() but with additional capability of distinguishing between C-headers and C-Source. For this purpose this function looks at the extension of the filename. This means that 'filename' can be a filename on some FTP server, too.

    Returns: A pointer to the result object. Do @em not delete the result object. After another call to KMimeMagic the returned result object changes its value since it is reused by KMimeMagic.

    UNKNOWN: Same functionality as findBufferType() but with additional capability of distinguishing between C-headers and C-Source.

    findBufferType

    public KMimeMagicResult findBufferType(byte[] p)
    Same functionality as above, except data is not read from a file. Instead a buffer can be supplied which is examined.

    Returns: A pointer to the result object. Do @em not delete the result object. After another call to KMimeMagic the returned result object changes its value since it is reused by KMimeMagic.

    UNKNOWN: Same functionality as above, except data is not read from a file.

    findFileType

    public KMimeMagicResult findFileType(String _filename)
    Try to find a MimeType for the given file. If no special MimeType is found, the default MimeType is returned. This function looks at the content of the file.

    Returns: A pointer to the result object. Do @em not delete the result object. After another call to KMimeMagic the returned result object changes its value since it is reused by KMimeMagic.

    UNKNOWN: Try to find a MimeType for the given file.

    initStatic

    protected static void initStatic()

    isDisposed

    public boolean isDisposed()
    Has the wrapped C++ instance been deleted?

    mergeBufConfig

    public boolean mergeBufConfig(String arg1)
    Merge an existing parse table with the data from the given buffer.

    Returns: true on success.

    UNKNOWN: Merge an existing parse table with the data from the given buffer.

    mergeConfig

    public boolean mergeConfig(String configFile)
    Merge an existing parse table with the data from the given file.

    Returns: true on success.

    UNKNOWN: Merge an existing parse table with the data from the given file.

    self

    public static KMimeMagic self()
    Returns a pointer to the unique KMimeMagic instance in this process.

    UNKNOWN: Returns a pointer to the unique KMimeMagic instance in this process.

    setFollowLinks

    public void setFollowLinks(boolean _enable)
    Enable/Disable follow-links. (Default is disabled.)

    UNKNOWN: Enable/Disable follow-links.