KDE 4.5 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

KZip Class Reference

from PyKDE4.kio import *

Inherits: KArchive

Detailed Description

A class for reading / writing zip archives.

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

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


Enumerations

Compression { NoCompression, DeflateCompression }
ExtraField { NoExtraField, ModificationTime, DefaultExtraField }

Methods

 __init__ (self, QString filename)
 __init__ (self, QIODevice dev)
 __init__ (self, KZip other)
bool closeArchive (self)
KZip.Compression compression (self)
bool doFinishWriting (self, long size)
bool doPrepareWriting (self, QString name, QString user, QString group, long size, long perm, long atime, long mtime, long ctime)
bool doWriteDir (self, QString name, QString user, QString group, long perm, long atime, long mtime, long ctime)
bool doWriteSymLink (self, QString name, QString target, QString user, QString group, long perm, long atime, long mtime, long ctime)
KZip.ExtraField extraField (self)
bool openArchive (self, QIODevice.OpenMode mode)
 setCompression (self, KZip.Compression c)
 setExtraField (self, KZip.ExtraField ef)
bool writeData (self, QString data, long size)

Method Documentation

__init__ (  self,
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")

__init__ (  self,
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

__init__ (  self,
KZip  other
)
bool closeArchive (   self )
KZip.Compression compression (   self )

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

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

bool doFinishWriting (  self,
long  size
)

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

Parameters:
size  the size of the file

Returns:
true if successful, false otherwise

bool doPrepareWriting (  self,
QString  name,
QString  user,
QString  group,
long  size,
long  perm,
long  atime,
long  mtime,
long  ctime
)
bool doWriteDir (  self,
QString  name,
QString  user,
QString  group,
long  perm,
long  atime,
long  mtime,
long  ctime
)
bool doWriteSymLink (  self,
QString  name,
QString  target,
QString  user,
QString  group,
long  perm,
long  atime,
long  mtime,
long  ctime
)
KZip.ExtraField extraField (   self )

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

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

bool openArchive (  self,
QIODevice.OpenMode  mode
)

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

setCompression (  self,
KZip.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()

setExtraField (  self,
KZip.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()

bool writeData (  self,
QString  data,
long  size
)

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


Enumeration Documentation

Compression

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

Enumerator:
NoCompression = 0
DeflateCompression = 1

ExtraField

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

Enumerator:
NoExtraField = 0
ModificationTime = 1
DefaultExtraField = 1

  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • plasma
  • polkitqt
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal