|
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 KArchiveDirectory * | directory () 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.
|
|
|
| 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.
|
|
KArchiveDirectory * | findOrCreate (const QString &path) |
| Ensures that path exists, create otherwise.
|
|
virtual bool | openArchive (QIODevice::OpenMode mode)=0 |
| Opens an archive for reading or writing.
|
|
virtual KArchiveDirectory * | rootDir () |
| 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) |
|
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
bool KArchive::addLocalDirectory |
( |
const QString & |
path, |
|
|
const QString & |
destName |
|
) |
| |
Writes a local directory into the archive, including all its contents, recursively.
Calls addLocalFile for each file to be added.
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
-
path | full path to an existing local directory, to be added to the archive. |
destName | the resulting name (or relative path) of the file in the archive. |
bool KArchive::addLocalFile |
( |
const QString & |
fileName, |
|
|
const QString & |
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
-
fileName | full path to an existing local file, to be added to the archive. |
destName | the resulting name (or relative path) of the file in the archive. |
virtual bool KArchive::doWriteDir |
( |
const QString & |
name, |
|
|
const QString & |
user, |
|
|
const QString & |
group, |
|
|
mode_t |
perm, |
|
|
const QDateTime & |
atime, |
|
|
const QDateTime & |
mtime, |
|
|
const QDateTime & |
ctime |
|
) |
| |
|
protectedpure virtual |
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
-
name | the name of the directory |
user | the user that owns the directory |
group | the group that owns the directory |
perm | permissions of the directory. Use 040755 if you don't have any other information. |
atime | time the file was last accessed |
mtime | modification time of the file |
ctime | time of last status change |
- See also
- writeDir
Implemented in K7Zip, KAr, KRcc, KTar, and KZip.
bool KArchive::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 ).
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
-
name | the name of the file |
user | the user that owns the file |
group | the group that owns the file |
size | the size of the file |
perm | permissions of the file |
atime | time the file was last accessed |
mtime | modification time of the file |
ctime | time of last status change |
bool KArchive::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.
The archive must be opened for writing first.
The necessary parent directories are created automatically if needed. For instance, writing "mydir/test1" does not require creating the directory "mydir" first.
This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be written out.
- Parameters
-
name | the name of the file |
data | the data to write |
perm | permissions of the file |
user | the user that owns the file |
group | the group that owns the file |
atime | time the file was last accessed |
mtime | modification time of the file |
ctime | time of last status change |