KArchive 5.109.0
Public Member Functions | Protected Member Functions | List of all members
KArchiveFile

Represents a file entry in a KArchive. More...

#include <KArchiveFile>

Public Member Functions

 KArchiveFile (KArchive *archive, const QString &name, int access, const QDateTime &date, const QString &user, const QString &group, const QString &symlink, qint64 pos, qint64 size)
 Creates a new file entry.
 
 ~KArchiveFile () override
 Destructor.
 
bool copyTo (const QString &dest) const
 Extracts the file to the directory dest.
 
virtual QIODevice * createDevice () const
 This method returns QIODevice (internal class: KLimitedIODevice) on top of the underlying QIODevice.
 
virtual QByteArray data () const
 Returns the data of the file.
 
bool isFile () const override
 Checks whether this entry is a file.
 
qint64 position () const
 Position of the data in the [uncompressed] archive.
 
void setSize (qint64 s)
 Set size of data, usually after writing the file.
 
qint64 size () const
 Size of the data.
 
- Public Member Functions inherited from KArchiveEntry
 KArchiveEntry (KArchive *archive, const QString &name, int access, const QDateTime &date, const QString &user, const QString &group, const QString &symlink)
 Creates a new entry.
 
QDateTime date () const
 Creation date of the file.
 
QString group () const
 Group of the user who created the file.
 
virtual bool isDirectory () const
 Checks whether the entry is a directory.
 
virtual bool isFile () const
 Checks whether the entry is a file.
 
QString name () const
 Name of the file without path.
 
mode_t permissions () const
 The permissions and mode flags as returned by the stat() function in st_mode.
 
QString symLinkTarget () const
 Symlink if there is one.
 
QString user () const
 User who created the file.
 

Protected Member Functions

void virtual_hook (int id, void *data) override
 
- Protected Member Functions inherited from KArchiveEntry
KArchivearchive () const
 
virtual void virtual_hook (int id, void *data)
 

Detailed Description

Represents a file entry in a KArchive.

A file in an archive.

See also
KArchive
KArchiveDirectory

Constructor & Destructor Documentation

◆ KArchiveFile()

KArchiveFile::KArchiveFile ( KArchive archive,
const QString &  name,
int  access,
const QDateTime &  date,
const QString &  user,
const QString &  group,
const QString &  symlink,
qint64  pos,
qint64  size 
)

Creates a new file entry.

Do not call this, KArchive takes care of it.

Parameters
archivethe entries archive
namethe name of the entry
accessthe permissions in unix format
datethe date (in seconds since 1970)
userthe user that owns the entry
groupthe group that owns the entry
symlinkthe symlink, or QString()
posthe position of the file in the directory
sizethe size of the file

◆ ~KArchiveFile()

KArchiveFile::~KArchiveFile ( )
override

Destructor.

Do not call this, KArchive takes care of it.

Member Function Documentation

◆ copyTo()

bool KArchiveFile::copyTo ( const QString &  dest) const

Extracts the file to the directory dest.

Parameters
destthe directory to extract to
Returns
true on success, false if the file (dest + '/' + name()) couldn't be created

◆ createDevice()

virtual QIODevice * KArchiveFile::createDevice ( ) const
virtual

This method returns QIODevice (internal class: KLimitedIODevice) on top of the underlying QIODevice.

This is obviously for reading only.

WARNING: Note that the ownership of the device is being transferred to the caller, who will have to delete it.

The returned device auto-opens (in readonly mode), no need to open it.

Returns
the QIODevice of the file

Reimplemented in KZipFileEntry.

◆ data()

virtual QByteArray KArchiveFile::data ( ) const
virtual

Returns the data of the file.

Call data() with care (only once per file), this data isn't cached.

Returns
the content of this file.

Reimplemented in KZipFileEntry.

◆ isFile()

bool KArchiveFile::isFile ( ) const
overridevirtual

Checks whether this entry is a file.

Returns
true, since this entry is a file

Reimplemented from KArchiveEntry.

◆ position()

qint64 KArchiveFile::position ( ) const

Position of the data in the [uncompressed] archive.

Returns
the position of the file

◆ setSize()

void KArchiveFile::setSize ( qint64  s)

Set size of data, usually after writing the file.

Parameters
sthe new size of the file

◆ size()

qint64 KArchiveFile::size ( ) const

Size of the data.

Returns
the size of the file

◆ virtual_hook()

void KArchiveFile::virtual_hook ( int  id,
void *  data 
)
overrideprotectedvirtual

Reimplemented from KArchiveEntry.