• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

Public Types | Public Member Functions | Protected Member Functions | List of all members
KZip Class Reference

#include <kzip.h>

Inheritance diagram for KZip:
KArchive

Public Types

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

Public Member Functions

 KZip (const TQString &filename)
 
 KZip (TQIODevice *dev)
 
virtual ~KZip ()
 
TQString fileName ()
 
void setExtraField (ExtraField ef)
 
ExtraField extraField () const
 
void setCompression (Compression c)
 
Compression compression () const
 
virtual bool writeFile (const TQString &name, const TQString &user, const TQString &group, uint size, const char *data)
 
virtual bool prepareWriting (const TQString &name, const TQString &user, const TQString &group, uint size)
 
bool writeSymLink (const TQString &name, const TQString &target, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool prepareWriting (const TQString &name, const TQString &user, const TQString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeFile (const TQString &name, const TQString &user, const TQString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime, const char *data)
 
bool writeData (const char *data, uint size)
 
virtual bool doneWriting (uint size)
 
- Public Member Functions inherited from KArchive
virtual bool open (int mode)
 
virtual void close ()
 
bool closeSucceeded () const
 
bool isOpened () const
 
int mode () const
 
TQIODevice * device () const
 
const KArchiveDirectory * directory () const
 
bool addLocalFile (const TQString &fileName, const TQString &destName)
 
bool addLocalDirectory (const TQString &path, const TQString &destName)
 
bool writeDir (const TQString &name, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeSymLink (const TQString &name, const TQString &target, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeFile (const TQString &name, const TQString &user, const TQString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime, const char *data)
 
bool prepareWriting (const TQString &name, const TQString &user, const TQString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeData (const char *data, uint size)
 

Protected Member Functions

virtual bool openArchive (int mode)
 
virtual bool closeArchive ()
 
virtual bool writeDir (const TQString &name, const TQString &user, const TQString &group)
 
virtual void virtual_hook (int id, void *data)
 
bool writeData_impl (const char *data, uint size)
 
bool prepareWriting_impl (const TQString &name, const TQString &user, const TQString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeSymLink_impl (const TQString &name, const TQString &target, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
- Protected Member Functions inherited from KArchive
 KArchive (TQIODevice *dev)
 
virtual KArchiveDirectory * rootDir ()
 
KArchiveDirectory * findOrCreate (const TQString &path)
 
void setDevice (TQIODevice *dev)
 
void setRootDir (KArchiveDirectory *rootDir)
 
bool prepareWriting_impl (const TQString &name, const TQString &user, const TQString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeFile_impl (const TQString &name, const TQString &user, const TQString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime, const char *data)
 
bool writeDir_impl (const TQString &name, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeSymLink_impl (const TQString &name, const TQString &target, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
 
bool writeData_impl (const char *data, uint size)
 

Additional Inherited Members

- Protected Types inherited from KArchive
enum  {
  VIRTUAL_WRITE_DATA = 1 , VIRTUAL_WRITE_SYMLINK , VIRTUAL_WRITE_DIR , VIRTUAL_WRITE_FILE ,
  VIRTUAL_PREPARE_WRITING
}
 

Detailed Description

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

You can use it in IO_ReadOnly or in IO_WriteOnly mode, and it behaves just as expected. It can also be used in IO_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 IO_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 holge.nosp@m.r-kd.nosp@m.e@hol.nosp@m.gis..nosp@m.net
Since
3.1

Definition at line 53 of file kzip.h.

Member Enumeration Documentation

◆ Compression

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 112 of file kzip.h.

◆ ExtraField

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)

Definition at line 89 of file kzip.h.

Constructor & Destructor Documentation

◆ KZip() [1/2]

KZip::KZip ( const TQString &  filename)

Creates an instance that operates on the given filename.

using the compression filter associated to given mimetype.

Parameters
filenameis a local path (e.g. "/home/holger/myfile.zip")

Definition at line 335 of file kzip.cpp.

◆ KZip() [2/2]

KZip::KZip ( TQIODevice *  dev)

Creates an instance that operates on the given device.

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

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

Definition at line 347 of file kzip.cpp.

◆ ~KZip()

KZip::~KZip ( )
virtual

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

Definition at line 354 of file kzip.cpp.

Member Function Documentation

◆ closeArchive()

bool KZip::closeArchive ( )
protectedvirtual

Closes the archive.

Implements KArchive.

Definition at line 855 of file kzip.cpp.

◆ compression()

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 1414 of file kzip.cpp.

◆ doneWriting()

bool KZip::doneWriting ( uint  size)
virtual

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

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

Implements KArchive.

Definition at line 1279 of file kzip.cpp.

◆ extraField()

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 1424 of file kzip.cpp.

◆ fileName()

TQString KZip::fileName ( )
inline

The name of the zip file, as passed to the constructor.

Null if you used the TQIODevice constructor.

Returns
the zip's file name, or null if a TQIODevice is used

Definition at line 84 of file kzip.h.

◆ openArchive()

bool KZip::openArchive ( int  mode)
protectedvirtual

Opens the archive for reading.

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

Parameters
modethe mode of the file

Implements KArchive.

Definition at line 369 of file kzip.cpp.

◆ prepareWriting()

bool KZip::prepareWriting ( const TQString &  name,
const TQString &  user,
const TQString &  group,
uint  size 
)
virtual

Alternative method for writing: call prepareWriting(), then feed the data in small chunks using writeData(), and call doneWriting() when done.

Parameters
namecan include subdirs e.g. path/to/the/file
userthe user owning the file
groupthe group owning the file
sizeunused argument
Returns
true if successful, false otherwise

Implements KArchive.

Definition at line 1088 of file kzip.cpp.

◆ setCompression()

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
cthe new compression mode
See also
compression()

Definition at line 1409 of file kzip.cpp.

◆ setExtraField()

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
efthe type of "extra field"
See also
extraField()

Definition at line 1419 of file kzip.cpp.

◆ writeData()

bool KZip::writeData ( const char *  data,
uint  size 
)

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

Parameters
dataa pointer to the data
sizethe size of the chunk
Returns
true if successful, false otherwise

Definition at line 1383 of file kzip.cpp.

◆ writeDir()

bool KZip::writeDir ( const TQString &  name,
const TQString &  user,
const TQString &  group 
)
protectedvirtual

If an archive is opened for writing then you can add new directories using this function.

KArchive won't write one directory twice.

Parameters
namethe name of the directory
userthe user that owns the directory
groupthe group that owns the directory
Todo:
TODO(BIC): make this a thin wrapper around writeDir(name,user,group,perm,atime,mtime,ctime) or eliminate it

Implements KArchive.

Definition at line 1054 of file kzip.cpp.

◆ writeFile()

bool KZip::writeFile ( const TQString &  name,
const TQString &  user,
const TQString &  group,
uint  size,
const char *  data 
)
virtual

If an archive is opened for writing then you can add a new file using this function.

This method takes the whole data at once.

Parameters
namecan include subdirs e.g. path/to/the/file
userthe user owning the file
groupthe group owning the file
sizethe size of the file
dataa pointer to the data
Returns
true if successful, false otherwise

Reimplemented from KArchive.

Definition at line 1070 of file kzip.cpp.


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

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.1
This website is maintained by Timothy Pearson.