• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
KFilterDev Class Reference

#include <kfilterdev.h>

Inheritance diagram for KFilterDev:
QIODevice

Public Member Functions

virtual ~KFilterDev ()
 
virtual bool atEnd () const
 
virtual void close ()
 
virtual bool open (QIODevice::OpenMode mode)
 
virtual bool seek (qint64)
 
void setOrigFileName (const QByteArray &fileName)
 
void setSkipHeaders ()
 

Static Public Member Functions

static QIODevice * device (QIODevice *inDevice, const QString &mimetype, bool autoDeleteInDevice=true)
 
static QIODevice * deviceForFile (const QString &fileName, const QString &mimetype=QString(), bool forceFilter=false)
 

Protected Member Functions

virtual qint64 readData (char *data, qint64 maxlen)
 
virtual qint64 writeData (const char *data, qint64 len)
 

Detailed Description

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.nosp@m.@kde.nosp@m..org

Definition at line 36 of file kfilterdev.h.

Constructor & Destructor Documentation

◆ ~KFilterDev()

KFilterDev::~KFilterDev ( )
virtual

Destructs the KFilterDev.

Calls close() if the filter device is still open.

Definition at line 54 of file kfilterdev.cpp.

Member Function Documentation

◆ atEnd()

bool KFilterDev::atEnd ( ) const
virtual

Definition at line 182 of file kfilterdev.cpp.

◆ close()

void KFilterDev::close ( )
virtual

Close after reading or writing.

If the KFilterBase's device was opened by open(), it will be closed.

Definition at line 128 of file kfilterdev.cpp.

◆ device()

QIODevice * KFilterDev::device ( QIODevice *  inDevice,
const QString &  mimetype,
bool  autoDeleteInDevice = true 
)
static

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.

Parameters
inDeviceinput device. Won't be deleted if autoDeleteInDevice = false
mimetypethe mime type for the filter
autoDeleteInDeviceif true, inDevice will be deleted automatically
Returns
a KFilterDev that filters the original stream. Must be deleted after using

Definition at line 84 of file kfilterdev.cpp.

◆ deviceForFile()

QIODevice * KFilterDev::deviceForFile ( const QString &  fileName,
const QString &  mimetype = QString(),
bool  forceFilter = false 
)
static

Reimplemented to return true.

KFilterDev is a sequential QIODevice. Well, not really, since it supports seeking and KZip uses that. 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.

Parameters
fileNamethe name of the file to filter
mimetypethe mime type of the file to filter, or QString() if unknown
forceFilterif 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.

Definition at line 64 of file kfilterdev.cpp.

◆ open()

bool KFilterDev::open ( QIODevice::OpenMode  mode)
virtual

Open for reading or writing.

If the KFilterBase's device is not opened, it will be opened.

Definition at line 97 of file kfilterdev.cpp.

◆ readData()

qint64 KFilterDev::readData ( char *  data,
qint64  maxlen 
)
protectedvirtual

Definition at line 189 of file kfilterdev.cpp.

◆ seek()

bool KFilterDev::seek ( qint64  pos)
virtual

That one can be quite slow, when going back.

Use with care.

Definition at line 142 of file kfilterdev.cpp.

◆ setOrigFileName()

void KFilterDev::setOrigFileName ( const QByteArray &  fileName)

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

Parameters
fileNamethe name of the original file

Definition at line 358 of file kfilterdev.cpp.

◆ setSkipHeaders()

void KFilterDev::setSkipHeaders ( )

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.

Definition at line 363 of file kfilterdev.cpp.

◆ writeData()

qint64 KFilterDev::writeData ( const char *  data,
qint64  len 
)
protectedvirtual

Definition at line 278 of file kfilterdev.cpp.


The documentation for this class was generated from the following files:
  • kfilterdev.h
  • kfilterdev.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal