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

tdeio/tdeio

Public Member Functions | Protected Types | Protected Member Functions | List of all members
KArchive Class Referenceabstract

#include <karchive.h>

Inheritance diagram for KArchive:
KAr KTar KZip

Public Member Functions

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)
 
virtual bool writeDir (const TQString &name, const TQString &user, const TQString &group)=0
 
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)
 
virtual bool writeFile (const TQString &name, const TQString &user, const TQString &group, uint size, const char *data)
 
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)
 
virtual bool prepareWriting (const TQString &name, const TQString &user, const TQString &group, uint size)=0
 
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)
 
virtual bool doneWriting (uint size)=0
 

Protected Types

enum  {
  VIRTUAL_WRITE_DATA = 1, VIRTUAL_WRITE_SYMLINK, VIRTUAL_WRITE_DIR, VIRTUAL_WRITE_FILE,
  VIRTUAL_PREPARE_WRITING
}
 

Protected Member Functions

 KArchive (TQIODevice *dev)
 
virtual bool openArchive (int mode)=0
 
virtual bool closeArchive ()=0
 
virtual KArchiveDirectory * rootDir ()
 
KArchiveDirectory * findOrCreate (const TQString &path)
 
void setDevice (TQIODevice *dev)
 
void setRootDir (KArchiveDirectory *rootDir)
 
virtual void virtual_hook (int id, void *data)
 
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)
 

Detailed Description

KArchive is a base class for reading and writing archives.

generic class for reading/writing archives

Author
David Faure faure.nosp@m.@kde.nosp@m..org

Definition at line 42 of file karchive.h.

Constructor & Destructor Documentation

KArchive::KArchive ( TQIODevice *  dev)
protected

Base constructor (protected since this is a pure virtual class).

Parameters
devthe I/O device where the archive reads its data Note that this can be a file, but also a data buffer, a compression filter, etc.

Definition at line 75 of file karchive.cpp.

Member Function Documentation

bool KArchive::addLocalDirectory ( const TQString &  path,
const TQString &  destName 
)

Writes a local directory into the archive, including all its contents, recursively.

Calls addLocalFile for each file to be added.

Since KDE 3.2 it will also add a path that is a symbolic link to a directory. The symbolic link will be dereferenced and the content of the directory it is pointing to added recursively. However, symbolic links under path will be stored as is.

Parameters
pathfull path to an existing local directory, to be added to the archive.
destNamethe resulting name (or relative path) of the file in the archive.

Definition at line 200 of file karchive.cpp.

bool KArchive::addLocalFile ( const TQString &  fileName,
const TQString &  destName 
)

Writes a local file into the archive.

The main difference with writeFile, is that this method minimizes memory usage, by not loading the whole file into memory in one go.

If fileName is a symbolic link, it will be written as is, i. e. it will not be resolved before.

Parameters
fileNamefull path to an existing local file, to be added to the archive.
destNamethe resulting name (or relative path) of the file in the archive.

Definition at line 136 of file karchive.cpp.

void KArchive::close ( )
virtual

Closes the archive.

Inherited classes might want to reimplement closeArchive instead.

See also
open

Definition at line 108 of file karchive.cpp.

virtual bool KArchive::closeArchive ( )
protectedpure virtual

Closes the archive.

Called by close.

Implemented in KZip, KTar, and KAr.

bool KArchive::closeSucceeded ( ) const

Use to check if close had any problem.

Returns
true if close succeded without problems
Since
3.5

Definition at line 124 of file karchive.cpp.

TQIODevice* KArchive::device ( ) const
inline

The underlying device.

Returns
the underlying device.

Definition at line 96 of file karchive.h.

const KArchiveDirectory * KArchive::directory ( ) const

If an archive is opened for reading, then the contents of the archive can be accessed via this function.

Returns
the directory of the archive

Definition at line 129 of file karchive.cpp.

virtual bool KArchive::doneWriting ( uint  size)
pure virtual

Call doneWriting after writing the data.

Parameters
sizethe size of the file
See also
prepareWriting()

Implemented in KZip, KTar, and KAr.

KArchiveDirectory * KArchive::findOrCreate ( const TQString &  path)
protected

Ensures that path exists, create otherwise.

This handles e.g. tar files missing directory entries, like mico-2.3.0.tar.gz :)

Parameters
paththe path of the directory
Returns
the directory with the given path

Definition at line 383 of file karchive.cpp.

bool KArchive::isOpened ( ) const
inline

Checks whether the archive is open.

Returns
true if the archive is opened

Definition at line 83 of file karchive.h.

int KArchive::mode ( ) const
inline

Returns the mode in which the archive was opened.

Returns
the mode in which the archive was opened (IO_ReadOnly or IO_WriteOnly)
See also
open()

Definition at line 90 of file karchive.h.

bool KArchive::open ( int  mode)
virtual

Opens the archive for reading or writing.

Inherited classes might want to reimplement openArchive instead.

Parameters
modemay be IO_ReadOnly or IO_WriteOnly
See also
close

Definition at line 91 of file karchive.cpp.

virtual bool KArchive::openArchive ( int  mode)
protectedpure virtual

Opens an archive for reading or writing.

Called by open.

Parameters
modemay be IO_ReadOnly or IO_WriteOnly

Implemented in KZip, KTar, and KAr.

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

Here's another way of writing a file into an archive: Call prepareWriting, then call writeData() as many times as wanted then call doneWriting( totalSize ).

For tar.gz files, you need to know the size before hand, since it is needed in the header. For zip files, size isn't used.

Parameters
namethe name of the file
userthe user that owns the file
groupthe group that owns the file
sizethe size of the file
Todo:
TODO(BIC): make this a thin non-virtual wrapper around prepareWriting(name,user,group,size,perm,atime,mtime,ctime) or eliminate it.

Implemented in KZip, KTar, and KAr.

bool KArchive::prepareWriting ( const TQString &  name,
const TQString &  user,
const TQString &  group,
uint  size,
mode_t  perm,
time_t  atime,
time_t  mtime,
time_t  ctime 
)

Here's another way of writing a file into an archive: Call prepareWriting, then call writeData() as many times as wanted then call doneWriting( totalSize ).

For tar.gz files, you need to know the size before hand, it is needed in the header! For zip files, size isn't used.

This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded.

Parameters
namethe name of the file
userthe user that owns the file
groupthe group that owns the file
sizethe size of the file
permpermissions of the file
atimetime the file was last accessed
mtimemodification time of the file
ctimecreation time of the file
Since
3.2
Todo:
TODO(BIC): make this virtual. For now use virtual hook.

Definition at line 235 of file karchive.cpp.

KArchiveDirectory * KArchive::rootDir ( )
protectedvirtual

Retrieves or create the root directory.

The default implementation assumes that openArchive() did the parsing, so it creates a dummy rootdir if none was set (write mode, or no '/' in the archive). Reimplement this to provide parsing/listing on demand.

Returns
the root directory

Definition at line 368 of file karchive.cpp.

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

Write data into the current file - to be called after calling prepareWriting.

Todo:
TODO(BIC) make virtual. For now virtual_hook allows reimplementing it.

Definition at line 353 of file karchive.cpp.

virtual bool KArchive::writeDir ( const TQString &  name,
const TQString &  user,
const TQString &  group 
)
pure virtual

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

Implemented in KZip, KTar, and KAr.

bool KArchive::writeDir ( const TQString &  name,
const TQString &  user,
const TQString &  group,
mode_t  perm,
time_t  atime,
time_t  mtime,
time_t  ctime 
)

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

KArchive won't write one directory twice.

This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded.

Parameters
namethe name of the directory
userthe user that owns the directory
groupthe group that owns the directory
permpermissions of the directory
atimetime the file was last accessed
mtimemodification time of the file
ctimecreation time of the file
Since
3.2
Todo:
TODO(BIC): make this virtual. For now use virtual hook

Definition at line 304 of file karchive.cpp.

bool KArchive::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.

If the file name is for example "mydir/test1" then the directory "mydir" is automatically appended first if that did not happen yet.

Parameters
namethe name of the file
userthe user that owns the file
groupthe group that owns the file
sizethe size of the file
datathe data to write (size bytes)
Todo:
TODO(BIC): make this a thin non-virtual wrapper around writeFile(name,user,group,size,perm,atime,mtime,ctime,data)

Reimplemented in KZip.

Definition at line 228 of file karchive.cpp.

bool KArchive::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 
)

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

If the file name is for example "mydir/test1" then the directory "mydir" is automatically appended first if that did not happen yet.

This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded.

Parameters
namethe name of the file
userthe user that owns the file
groupthe group that owns the file
sizethe size of the file
permpermissions of the file
atimetime the file was last accessed
mtimemodification time of the file
ctimecreation time of the file
datathe data to write (size bytes)
Since
3.2
Todo:
TODO(BIC): make virtual. For now use virtual hook

Definition at line 259 of file karchive.cpp.

bool KArchive::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 
)

Writes a symbolic link to the archive if the archive must be opened for writing.

Parameters
namename of symbolic link
targettarget of symbolic link
userthe user that owns the directory
groupthe group that owns the directory
permpermissions of the directory
atimetime the file was last accessed
mtimemodification time of the file
ctimecreation time of the file
Since
3.2
Todo:
TODO(BIC) make virtual. For now it must be implemented by virtual_hook.

Definition at line 327 of file karchive.cpp.


The documentation for this class was generated from the following files:
  • karchive.h
  • karchive.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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.8.8
This website is maintained by Timothy Pearson.