# class KTarBase | generic class for reading/writing tar archives Common functionality for KTarGz and KTarData. More...
Contains pure virtuals
Definition | `#include <ktar.h>`
Inherited by | KTarData, KTarGz
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- virtual bool open ( int mode )
- virtual void close ()
- bool isOpened () const
- void writeDir ( const QString& name, const QString& user, const QString& group )
- void writeFile ( const QString& name, const QString& user, const QString& group, uint size, const char* data )
- const KTarDirectory* directory () const

#### Protected Methods

- KTarBase ()
- virtual ~KTarBase ()
- virtual int read ( char * buffer, int len )
- virtual void write ( const char * buffer, int len )
- virtual int position ()
- KTarDirectory * findOrCreate ( const QString & path )
- void fillBuffer ( char * buffer, const char * mode, int size, char typeflag, const char * uname, const char * gname )

#### Protected Members

- KTarDirectory* m_dir
- bool m_open
- QStringList m_dirList
- char m_mode

## Detailed Description

KTarBase () | ### KTarBase

[protected]

~KTarBase () | ### ~KTarBase

[protected virtual]

bool open ( int mode ) | ### open

[virtual]

Opens the tar file/data for reading or writing.

Parameters:

mode | may be IO_ReadOnly or IO_WriteOnly

See also: close

void close () | ### close

[virtual]

Closes the tar file/data.

See also: open

bool isOpened () | ### isOpened

[const]

Returns: true if the file is opened

void writeDir ( const QString& name, const QString& user, const QString& group ) | ### writeDir

If a tar file is opened for writing then you can add new directories using this function. KTar won't write one directory twice.

void writeFile ( const QString& name, const QString& user, const QString& group, uint size, const char* data ) | ### writeFile

If a tar file 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.

const KTarDirectory* directory () | ### directory

[const]

If a tar file is opened for reading, then the contents of the file can be accessed via this function.

int read ( char * buffer, int len ) | ### read

[protected pure virtual]

Read `len` data into `buffer` - reimplemented

Returns: length read

void write ( const char * buffer, int len ) | ### write

[protected pure virtual]

Write `len` data from `buffer` - reimplemented

int position () | ### position

[protected pure virtual]

Returns: the current position - reimplemented

KTarDirectory * findOrCreate ( const QString & path ) | ### findOrCreate

[protected]

Ensure path exists, create otherwise. This handles tar files missing directory entries, like mico-2.3.0.tar.gz :)

void fillBuffer ( char * buffer, const char * mode, int size, char typeflag, const char * uname, const char * gname ) | ### fillBuffer

[protected]

Fills `buffer` for writing a file as required by the tar format Has to be called LAST, since it does the checksum (normally, only the name has to be filled in before)

Parameters:

mode | is expected to be 6 chars long, [uname and gname 31].

KTarDirectory* m_dir | ### m_dir

[protected]

bool m_open | ### m_open

[protected]

QStringList m_dirList | ### m_dirList

[protected]

char m_mode | ### m_mode

[protected]

- Author: David Faure <faure@kde.org>
- Generated: root@sparc.ports.openbsd.org on Wed May 2 09:40:40 2001, using kdoc 2.0a53.