# class KFilterDev

###

Module | kdecore
Namespace |
Class | KFilterDev
Inherits | QIODevice

A class for reading and writing compressed data onto a device (e.g. file, but other usages are possible, like a buffer or a socket).

To simply read/write compressed files, see deviceForFile.

Author David Faure <faure@kde.org>

### methods

- KFilterDev (filter, autoDeleteFilterBase)

  returns ctor
  Not implemented
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  filter | KFilterBase |
  autoDeleteFilterBase | bool | 0

  Constructs a KFilterDev for a given filter (e.g. gzip, bzip2 etc.).

  filter - the KFilterBase to use

  autoDeleteFilterBase - when true this object will become the owner of filter.

- KFilterDev (a0, a1)

  returns ctor
  Not implemented
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | KFilterBase |
  a1 | bool | 0

- atEnd ( )

  returns bool

- close ( )

  returns Nothing

  Close after reading or writing. If the KFilterBase's device was opened by open(), it will be closed.

- device (inDevice, mimetype, autoDeleteInDevice)

  returns QIODevice
  static

  Argument | Type | Default
  --- | --- | ---
  inDevice | QIODevice |
  mimetype | QString |
  autoDeleteInDevice | bool | 1

  Creates an i/o device that is able to read from the QIODevice inDevice, whether the data is compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used.

  The compression filter to be used is determined mimetype . Pass "application/x-gzip" or "application/x-bzip" to use the corresponding decompression filter.

  Warning: application/x-bzip may not be available. In that case 0 will be returned !

  The returned QIODevice has to be deleted after using.

  inDevice - input device. Won't be deleted if autoDeleteInDevice = false

  mimetype - the mime type for the filter

  autoDeleteInDevice - if true, inDevice will be deleted automatically Returns a QIODevice that filters the original stream. Must be deleted after using

- deviceForFile (fileName, mimetype, forceFilter)

  returns QIODevice
  static

  Argument | Type | Default
  --- | --- | ---
  fileName | QString |
  mimetype | QString | QString()
  forceFilter | bool | 0

  Creates an i/o device that is able to read from fileName, whether it's compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used.

  The compression filter to be used is determined from the fileName if mimetype is empty. Pass "application/x-gzip" or "application/x-bzip" to force the corresponding decompression filter, if available.

  Warning: application/x-bzip may not be available. In that case a QFile opened on the compressed data will be returned ! Use KFilterBase.findFilterByMimeType and code similar to what deviceForFile is doing, to better control what's happening.

  The returned QIODevice has to be deleted after using.

  fileName - the name of the file to filter

  mimetype - the mime type of the file to filter, or QString() if unknown

  forceFilter - if true, the function will either find a compression filter, or return 0. If false, it will always return a QIODevice. If no filter is available it will return a simple QFile. This can be useful if the file is usable without a filter. Returns if a filter has been found, the QIODevice for the filter. If the filter does not exist, the return value depends on forceFilter. The returned QIODevice has to be deleted after using.

- open (mode)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  mode | QIODevice.OpenMode |

  Open for reading or writing. If the KFilterBase's device is not opened, it will be opened.

- readData (data, maxlen)

  returns qint64

  Argument | Type | Default
  --- | --- | ---
  data | char |
  maxlen | qint64 |

- seek (a0)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  a0 | qint64 |

  That one can be quite slow, when going back. Use with care.

- setOrigFileName (fileName)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  fileName | QByteArray |

  For writing gzip compressed files only: set the name of the original file, to be used in the gzip header.

  fileName - the name of the original file

- setSkipHeaders ( )

  returns Nothing

  Call this let this device skip the gzip headers when reading/writing. This way KFilterDev (with gzip filter) can be used as a direct wrapper around zlib - this is used by KZip.

- writeData (data, len)

  returns qint64

  Argument | Type | Default
  --- | --- | ---
  data | char |
  len | qint64 |