KMimeMagic Class Reference
#include <kmimemagic.h>
Public Member Functions | |
KMimeMagic () | |
KMimeMagic (const QString &configFile) | |
~KMimeMagic () | |
bool | mergeConfig (const QString &configFile) |
bool | mergeBufConfig (char *) |
void | setFollowLinks (bool _enable) |
KMimeMagicResult * | findFileType (const QString &_filename) |
KMimeMagicResult * | findBufferType (const QByteArray &p) |
KMimeMagicResult * | findBufferFileType (const QByteArray &, const QString &filename) |
Static Public Member Functions | |
KMimeMagic * | self () |
Static Protected Member Functions | |
void | initStatic () |
Protected Attributes | |
KMimeMagicResult * | magicResult |
Static Protected Attributes | |
KMimeMagic * | s_pSelf |
Detailed Description
- Deprecated:
- Use KMimeType::findByContent() instead 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.
Definition at line 101 of file kmimemagic.h.
Constructor & Destructor Documentation
|
Create a parser and initialize it with the KDE-global data: the "magic" config file as well as the snippets from share/config/magic.
Definition at line 2098 of file kmimemagic.cpp. References KGlobal::dirs(), endl(), KStandardDirs::findAllResources(), k_funcinfo, kdWarning(), locate(), and mergeConfig(). |
|
Create a parser and initialize it with the given config file.
Definition at line 2110 of file kmimemagic.cpp. |
|
Destroy the parser.
Definition at line 2139 of file kmimemagic.cpp. References magicResult. |
Member Function Documentation
|
Merge an existing parse table with the data from the given file.
Definition at line 2156 of file kmimemagic.cpp. References endl(), k_funcinfo, kdDebug(), and mergeConfig(). Referenced by KMimeMagic(), and mergeConfig(). |
|
Merge an existing parse table with the data from the given buffer.
Definition at line 2174 of file kmimemagic.cpp. References mergeBufConfig(). Referenced by mergeBufConfig(). |
|
Enable/Disable follow-links. (Default is disabled.) Definition at line 2191 of file kmimemagic.cpp. References setFollowLinks(). Referenced by setFollowLinks(). |
|
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.
Definition at line 2254 of file kmimemagic.cpp. References endl(), findFileType(), kdDebug(), magicResult, KMimeMagicResult::setAccuracy(), KMimeMagicResult::setInvalid(), and KMimeMagicResult::setMimeType(). Referenced by KMimeType::findByFileContent(), KMimeType::findByURL(), and findFileType(). |
|
Same functionality as above, except data is not read from a file. Instead a buffer can be supplied which is examined.
Definition at line 2197 of file kmimemagic.cpp. References findBufferType(), magicResult, KMimeMagicResult::setAccuracy(), KMimeMagicResult::setInvalid(), and KMimeMagicResult::setMimeType(). Referenced by findBufferFileType(), findBufferType(), and KMimeType::findByContent(). |
|
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.
Definition at line 2243 of file kmimemagic.cpp. References findBufferFileType(), and findBufferType(). Referenced by findBufferFileType(). |
|
Returns a pointer to the unique KMimeMagic instance in this process.
Definition at line 40 of file kmimemagic.cpp. Referenced by KMimeType::findByContent(), KMimeType::findByFileContent(), and KMimeType::findByURL(). |
Member Data Documentation
|
The result type.
Definition at line 197 of file kmimemagic.h. Referenced by findBufferType(), findFileType(), and ~KMimeMagic(). |
The documentation for this class was generated from the following files: