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

KRcc is a class for reading dynamic binary resources created by Qt's rcc tool from a .qrc file and the files it points to. More...

#include <krcc.h>

Public Member Functions

 KRcc (const QString &filename)
 Creates an instance that operates on the given filename.
 
 ~KRcc () override
 If the rcc file is still opened, then it will be closed automatically by the destructor.
 
- Public Member Functions inherited from KArchive
bool addLocalDirectory (const QString &path, const QString &destName)
 Writes a local directory into the archive, including all its contents, recursively.
 
bool addLocalFile (const QString &fileName, const QString &destName)
 Writes a local file into the archive.
 
virtual bool close ()
 Closes the archive.
 
QIODevice * device () const
 The underlying device.
 
const KArchiveDirectorydirectory () const
 If an archive is opened for reading, then the contents of the archive can be accessed via this function.
 
QString errorString () const
 Returns a description of the last error.
 
QString fileName () const
 The name of the archive file, as passed to the constructor that takes a fileName, or an empty string if you used the QIODevice constructor.
 
bool finishWriting (qint64 size)
 Call finishWriting after writing the data.
 
bool isOpen () const
 Checks whether the archive is open.
 
QIODevice::OpenMode mode () const
 Returns the mode in which the archive was opened.
 
virtual bool open (QIODevice::OpenMode mode)
 Opens the archive for reading or writing.
 
bool prepareWriting (const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm=0100644, const QDateTime &atime=QDateTime(), const QDateTime &mtime=QDateTime(), const QDateTime &ctime=QDateTime())
 Here's another way of writing a file into an archive: Call prepareWriting(), then call writeData() as many times as wanted then call finishWriting( totalSize ).
 
virtual bool writeData (const char *data, qint64 size)
 Write data into the current file - to be called after calling prepareWriting.
 
bool writeDir (const QString &name, const QString &user=QString(), const QString &group=QString(), mode_t perm=040755, const QDateTime &atime=QDateTime(), const QDateTime &mtime=QDateTime(), const QDateTime &ctime=QDateTime())
 If an archive is opened for writing then you can add new directories using this function.
 
bool writeFile (const QString &name, const QByteArray &data, mode_t perm=0100644, const QString &user=QString(), const QString &group=QString(), const QDateTime &atime=QDateTime(), const QDateTime &mtime=QDateTime(), const QDateTime &ctime=QDateTime())
 Writes a new file into the archive.
 
bool writeFile (const QString &name, const QString &user, const QString &group, const char *data, qint64 size, mode_t perm=0100644, const QDateTime &atime=QDateTime(), const QDateTime &mtime=QDateTime(), const QDateTime &ctime=QDateTime())
 
bool writeSymLink (const QString &name, const QString &target, const QString &user=QString(), const QString &group=QString(), mode_t perm=0120755, const QDateTime &atime=QDateTime(), const QDateTime &mtime=QDateTime(), const QDateTime &ctime=QDateTime())
 Writes a symbolic link to the archive if supported.
 

Protected Member Functions

bool closeArchive () override
 Unregisters the .rcc resource from the QResource system.
 
bool doFinishWriting (qint64 size) override
 Called after writing the data.
 
bool doPrepareWriting (const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) override
 This virtual method must be implemented by subclasses.
 
bool doWriteDir (const QString &name, const QString &user, const QString &group, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) override
 Write a directory to the archive.
 
bool doWriteSymLink (const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) override
 Writes a symbolic link to the archive.
 
bool openArchive (QIODevice::OpenMode mode) override
 Registers the .rcc resource in the QResource system under a unique identifier, then lists that, and creates the KArchiveFile/KArchiveDirectory entries.
 
void virtual_hook (int id, void *data) override
 
- Protected Member Functions inherited from KArchive
 KArchive (const QString &fileName)
 Base constructor (protected since this is a pure virtual class).
 
 KArchive (QIODevice *dev)
 Base constructor (protected since this is a pure virtual class).
 
virtual bool closeArchive ()=0
 Closes the archive.
 
virtual bool createDevice (QIODevice::OpenMode mode)
 Can be reimplemented in order to change the creation of the device (when using the fileName constructor).
 
virtual bool doFinishWriting (qint64 size)=0
 Called after writing the data.
 
virtual bool doPrepareWriting (const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime)=0
 This virtual method must be implemented by subclasses.
 
virtual bool doWriteDir (const QString &name, const QString &user, const QString &group, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime)=0
 Write a directory to the archive.
 
virtual bool doWriteSymLink (const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime)=0
 Writes a symbolic link to the archive.
 
KArchiveDirectoryfindOrCreate (const QString &path)
 Ensures that path exists, create otherwise.
 
virtual bool openArchive (QIODevice::OpenMode mode)=0
 Opens an archive for reading or writing.
 
virtual KArchiveDirectoryrootDir ()
 Retrieves or create the root directory.
 
void setDevice (QIODevice *dev)
 Can be called by derived classes in order to set the underlying device.
 
void setErrorString (const QString &errorStr)
 Sets error description.
 
void setRootDir (KArchiveDirectory *rootDir)
 Derived classes call setRootDir from openArchive, to set the root directory after parsing an existing archive.
 
virtual void virtual_hook (int id, void *data)
 

Detailed Description

KRcc is a class for reading dynamic binary resources created by Qt's rcc tool from a .qrc file and the files it points to.

Writing is not supported.

A class for reading rcc resources.

Since
5.3

Constructor & Destructor Documentation

◆ KRcc()

KRcc::KRcc ( const QString &  filename)

Creates an instance that operates on the given filename.

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

◆ ~KRcc()

KRcc::~KRcc ( )
override

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

Member Function Documentation

◆ closeArchive()

bool KRcc::closeArchive ( )
overrideprotectedvirtual

Unregisters the .rcc resource from the QResource system.

Implements KArchive.

◆ doFinishWriting()

bool KRcc::doFinishWriting ( qint64  size)
overrideprotectedvirtual

Called after writing the data.

This virtual method must be implemented by subclasses.

Parameters
sizethe size of the file
See also
finishWriting()

Implements KArchive.

◆ doPrepareWriting()

bool KRcc::doPrepareWriting ( const QString &  name,
const QString &  user,
const QString &  group,
qint64  size,
mode_t  perm,
const QDateTime &  atime,
const QDateTime &  mtime,
const QDateTime &  ctime 
)
overrideprotectedvirtual

This virtual method must be implemented by subclasses.

Depending on the archive type not all metadata might be used.

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. Use 0100644 if you don't have any more specific permissions to set.
atimetime the file was last accessed
mtimemodification time of the file
ctimetime of last status change
See also
prepareWriting

Implements KArchive.

◆ doWriteDir()

bool KRcc::doWriteDir ( const QString &  name,
const QString &  user,
const QString &  group,
mode_t  perm,
const QDateTime &  atime,
const QDateTime &  mtime,
const QDateTime &  ctime 
)
overrideprotectedvirtual

Write a directory to the archive.

This virtual method must be implemented by subclasses.

Depending on the archive type not all metadata might be used.

Parameters
namethe name of the directory
userthe user that owns the directory
groupthe group that owns the directory
permpermissions of the directory. Use 040755 if you don't have any other information.
atimetime the file was last accessed
mtimemodification time of the file
ctimetime of last status change
See also
writeDir

Implements KArchive.

◆ doWriteSymLink()

bool KRcc::doWriteSymLink ( const QString &  name,
const QString &  target,
const QString &  user,
const QString &  group,
mode_t  perm,
const QDateTime &  atime,
const QDateTime &  mtime,
const QDateTime &  ctime 
)
overrideprotectedvirtual

Writes a symbolic link to the archive.

This virtual method must be implemented by subclasses.

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
ctimetime of last status change
See also
writeSymLink

Implements KArchive.

◆ openArchive()

bool KRcc::openArchive ( QIODevice::OpenMode  mode)
overrideprotectedvirtual

Registers the .rcc resource in the QResource system under a unique identifier, then lists that, and creates the KArchiveFile/KArchiveDirectory entries.

Implements KArchive.

◆ virtual_hook()

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

Reimplemented from KArchive.