|
|
The goal of KMimeMagic is to determine auto-magically the type of file, not only using its extension, but also reading its contents. Unless specified otherwise, KMimeMagic uses $KDEDIR/share/mimelnk/magic for this purpose.
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
KMimeMagic ( const char * ) |
Create a parser, initialize it with the give config file.
~KMimeMagic () |
Destroys the parser
bool mergeConfig ( const char * ) |
Merge an existing parse table with the data from the given file.
Returns: true on success.
bool mergeBufConfig (char *) |
Merge an existing parse table with the data from the given buffer.
Returns: : true on success.
void setFollowLinks ( bool _enable ) |
Enable/Disable follow-links. (Default is off)
KMimeMagicResult* findFileType ( const char *_filename ) |
Tries 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 NOT delete the result object. After another call to KMimeMagic the returned result object changes its value since it is reused by KMimeMagic.
KMimeMagicResult* findBufferType ( const char *_sample, int _len ) |
Same functionality as above, except data is not read from a file. Instead a buffer can be supplied which is examined. The integer parameter supplies the lenght of the buffer.
Returns: a pointer to the result. Do NOT delete the result object. After another call to KMimeMagic the returned result object changes its value.
KMimeMagicResult * findBufferFileType ( const char *_sample, int _len, const char *_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 NOT delete the result object. After another call to KMimeMagic the returned result object changes its value since it is resued by KMimeMagic.
KMimeMagic* self () |
Returns: a pointer to the unique KMimeMagic instance in this process
KMimeMagicResult * magicResult |
The result type.
Generated by: root@tantive.terraplex.com on Sun Feb 27 17:39:31 2000, using kdoc 2.0a33. |