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

Represents a directory entry in a KArchive. More...

#include <KArchiveDirectory>

Public Member Functions

 KArchiveDirectory (KArchive *archive, const QString &name, int access, const QDateTime &date, const QString &user, const QString &group, const QString &symlink)
 Creates a new directory entry.
 
void addEntry (KArchiveEntry *)
 
bool addEntryV2 (KArchiveEntry *)
 
bool copyTo (const QString &dest, bool recursive=true) const
 Extracts all entries in this archive directory to the directory dest.
 
QStringList entries () const
 Returns a list of sub-entries.
 
const KArchiveEntryentry (const QString &name) const
 Returns the entry in the archive with the given name.
 
const KArchiveFilefile (const QString &name) const
 Returns the file entry in the archive with the given name.
 
bool isDirectory () const override
 Checks whether this entry is a directory.
 
void removeEntry (KArchiveEntry *)
 
- 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 directory entry in a KArchive.

A directory in an archive.

See also
KArchive
KArchiveFile

Constructor & Destructor Documentation

◆ KArchiveDirectory()

KArchiveDirectory::KArchiveDirectory ( KArchive archive,
const QString &  name,
int  access,
const QDateTime &  date,
const QString &  user,
const QString &  group,
const QString &  symlink 
)

Creates a new directory entry.

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()

Member Function Documentation

◆ copyTo()

bool KArchiveDirectory::copyTo ( const QString &  dest,
bool  recursive = true 
) const

Extracts all entries in this archive directory to the directory dest.

Parameters
destthe directory to extract to
recursiveif set to true, subdirectories are extracted as well
Returns
true on success, false if the directory (dest + '/' + name()) couldn't be created

◆ entries()

QStringList KArchiveDirectory::entries ( ) const

Returns a list of sub-entries.

Note that the list is not sorted, it's even in random order (due to using a hashtable). Use sort() on the result to sort the list by filename.

Returns
the names of all entries in this directory (filenames, no path).

◆ entry()

const KArchiveEntry * KArchiveDirectory::entry ( const QString &  name) const

Returns the entry in the archive with the given name.

The entry could be a file or a directory, use isFile() to find out which one it is.

Parameters
namemay be "test1", "mydir/test3", "mydir/mysubdir/test3", etc.
Returns
a pointer to the entry in the directory, or a null pointer if there is no such entry.

◆ file()

const KArchiveFile * KArchiveDirectory::file ( const QString &  name) const

Returns the file entry in the archive with the given name.

If the entry exists and is a file, a KArchiveFile is returned. Otherwise, a null pointer is returned. This is a convenience method for entry(), when we know the entry is expected to be a file.

Parameters
namemay be "test1", "mydir/test3", "mydir/mysubdir/test3", etc.
Returns
a pointer to the file entry in the directory, or a null pointer if there is no such file entry.
Since
5.3

◆ isDirectory()

bool KArchiveDirectory::isDirectory ( ) const
overridevirtual

Checks whether this entry is a directory.

Returns
true, since this entry is a directory

Reimplemented from KArchiveEntry.

◆ virtual_hook()

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

Reimplemented from KArchiveEntry.