• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

KZip Class Reference

This class implements a kioslave to access zip files from KDE. More...

#include <kzip.h>

Inheritance diagram for KZip:
KArchive

List of all members.

Public Types

enum  Compression { NoCompression = 0, DeflateCompression = 1 }
enum  ExtraField { NoExtraField = 0, ModificationTime = 1, DefaultExtraField = 1 }

Public Member Functions

Compression compression () const
ExtraField extraField () const
 KZip (QIODevice *dev)
 KZip (const QString &filename)
void setCompression (Compression c)
void setExtraField (ExtraField ef)
virtual bool writeData (const char *data, qint64 size)
virtual ~KZip ()

Protected Member Functions

virtual bool closeArchive ()
virtual bool doFinishWriting (qint64 size)
virtual bool doPrepareWriting (const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
virtual bool doWriteDir (const QString &name, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
virtual bool doWriteSymLink (const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
virtual bool openArchive (QIODevice::OpenMode mode)
virtual void virtual_hook (int id, void *data)

Detailed Description

This class implements a kioslave to access zip files from KDE.

You can use it in QIODevice::ReadOnly or in QIODevice::WriteOnly mode, and it behaves just as expected. It can also be used in QIODevice::ReadWrite mode, in this case one can append files to an existing zip archive. When you append new files, which are not yet in the zip, it works as expected, i.e. the files are appended at the end. When you append a file, which is already in the file, the reference to the old file is dropped and the new one is added to the zip - but the old data from the file itself is not deleted, it is still in the zipfile. so when you want to have a small and garbage-free zipfile, just read the contents of the appended zip file and write it to a new one in QIODevice::WriteOnly mode. This is especially important when you don't want to leak information of how intermediate versions of files in the zip were looking. For more information on the zip fileformat go to http://www.pkware.com/products/enterprise/white_papers/appnote.html A class for reading/writing zip archives.

Author:
Holger Schroeder <holger-kde@holgis.net>

Definition at line 44 of file kzip.h.


Member Enumeration Documentation

enum KZip::Compression

Describes the compression type for a given file in the Zip archive.

Enumerator:
NoCompression 

Uncompressed.

DeflateCompression 

Deflate compression method.

Definition at line 96 of file kzip.h.

enum KZip::ExtraField

Describes the contents of the "extra field" for a given file in the Zip archive.

Enumerator:
NoExtraField 

No extra field.

ModificationTime 

Modification time ("extended timestamp" header).

DefaultExtraField 

Definition at line 73 of file kzip.h.


Constructor & Destructor Documentation

KZip::KZip ( const QString &  filename  ) 

Creates an instance that operates on the given filename.

using the compression filter associated to given mimetype.

Parameters:
filename is a local path (e.g. "/home/holger/myfile.zip")

Definition at line 333 of file kzip.cpp.

KZip::KZip ( QIODevice *  dev  ) 

Creates an instance that operates on the given device.

The device can be compressed (KFilterDev) or not (QFile, etc.).

Warning:
Do not assume that giving a QFile here will decompress the file, in case it's compressed!
Parameters:
dev the device to access

Definition at line 338 of file kzip.cpp.

KZip::~KZip (  )  [virtual]

If the zip file is still opened, then it will be closed automatically by the destructor.

Definition at line 343 of file kzip.cpp.


Member Function Documentation

bool KZip::closeArchive (  )  [protected, virtual]

Closes the archive.

Implements KArchive.

Definition at line 808 of file kzip.cpp.

KZip::Compression KZip::compression (  )  const

The current compression mode that will be used for new files.

Returns:
the current compression mode
See also:
setCompression()

Definition at line 1276 of file kzip.cpp.

bool KZip::doFinishWriting ( qint64  size  )  [protected, virtual]

Write data to a file that has been created using prepareWriting().

Parameters:
size the size of the file
Returns:
true if successful, false otherwise

Implements KArchive.

Definition at line 1180 of file kzip.cpp.

bool KZip::doPrepareWriting ( const QString &  name,
const QString &  user,
const QString &  group,
qint64  size,
mode_t  perm,
time_t  atime,
time_t  mtime,
time_t  ctime 
) [protected, virtual]

Reimplemented from KArchive.

Implements KArchive.

Definition at line 1009 of file kzip.cpp.

bool KZip::doWriteDir ( const QString &  name,
const QString &  user,
const QString &  group,
mode_t  perm,
time_t  atime,
time_t  mtime,
time_t  ctime 
) [protected, virtual]

Reimplemented from KArchive.

Implements KArchive.

Definition at line 998 of file kzip.cpp.

bool KZip::doWriteSymLink ( const QString &  name,
const QString &  target,
const QString &  user,
const QString &  group,
mode_t  perm,
time_t  atime,
time_t  mtime,
time_t  ctime 
) [protected, virtual]

Reimplemented from KArchive.

Implements KArchive.

Definition at line 1217 of file kzip.cpp.

KZip::ExtraField KZip::extraField (  )  const

The current type of "extra field" that will be used for new files.

Returns:
the current type of "extra field"
See also:
setExtraField()

Definition at line 1286 of file kzip.cpp.

bool KZip::openArchive ( QIODevice::OpenMode  mode  )  [protected, virtual]

Opens the archive for reading.

Parses the directory listing of the archive and creates the KArchiveDirectory/KArchiveFile entries.

Parameters:
mode the mode of the file

Implements KArchive.

Definition at line 351 of file kzip.cpp.

void KZip::setCompression ( Compression  c  ) 

Call this before writeFile or prepareWriting, to define whether the next files to be written should be compressed or not.

Parameters:
c the new compression mode
See also:
compression()

Definition at line 1271 of file kzip.cpp.

void KZip::setExtraField ( ExtraField  ef  ) 

Call this before writeFile or prepareWriting, to define what the next file to be written should have in its extra field.

Parameters:
ef the type of "extra field"
See also:
extraField()

Definition at line 1281 of file kzip.cpp.

void KZip::virtual_hook ( int  id,
void *  data 
) [protected, virtual]

Reimplemented from KArchive.

Definition at line 1249 of file kzip.cpp.

bool KZip::writeData ( const char *  data,
qint64  size 
) [virtual]

Write data to a file that has been created using prepareWriting().

Parameters:
data a pointer to the data
size the size of the chunk
Returns:
true if successful, false otherwise

Reimplemented from KArchive.

Definition at line 1254 of file kzip.cpp.


The documentation for this class was generated from the following files:
  • kzip.h
  • kzip.cpp

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal