KVIrc
4.9.2
DeveloperAPIs
|
This class is used to create KVIrc package files. More...
#include <KviPackageWriter.h>
Public Types | |
enum | AddFileFlags { NoCompression = 1, FollowSymLinks = 2 } |
enum | PackFlags { NoProgressDialog = 1 } |
Public Member Functions | |
bool | addDirectory (const QString &szLocalDirectoryName, const QString &szTargetDirectoryPrefix, kvi_u32_t uAddFileFlags=0) |
Adds a directory to the package. More... | |
bool | addFile (const QString &szLocalFileName, const QString &szTargetFileName, kvi_u32_t uAddFileFlags=0) |
Adds a file to the package. More... | |
void | addInfoField (const QString &szName, const QString &szValue) |
Adds an info field as a name=value pair. More... | |
void | addInfoField (const QString &szName, QByteArray *pArray) |
Adds an info field as a name=value pair. More... | |
KviPackageWriter () | |
Creates the package writer object. More... | |
bool | pack (const QString &szFileName, kvi_u32_t uPackFlags=0) |
Attempts to pack everything and store it as the specified file. More... | |
virtual | ~KviPackageWriter () |
Destroys the object. More... | |
Public Member Functions inherited from KviPackageIOEngine | |
KviPointerHashTable< QString, QByteArray > * | binaryInfoFields () |
Returns the binary info fields. More... | |
KviPackageIOEngine () | |
Creates the I/O engine object. More... | |
const QString & | lastError () |
Returns the last error. More... | |
KviPointerHashTable< QString, QString > * | stringInfoFields () |
Returns the string info fields. More... | |
virtual | ~KviPackageIOEngine () |
Destroys the object. More... | |
Private Member Functions | |
bool | addFileInternal (const QFileInfo *fi, const QString &szLocalFileName, const QString &szTargetFileName, kvi_u32_t uAddFileFlags=0) |
Adds a file to the package. More... | |
bool | packFile (KviFile *pFile, KviPackageWriterDataField *pDataField) |
Attempts to pack everything and store it as the specified file. More... | |
bool | packInternal (const QString &szFileName, kvi_u32_t uPackFlags=0) |
Attempts to pack everything and store it as the specified file. More... | |
Private Attributes | |
KviPackageWriterPrivate * | m_p |
Additional Inherited Members | |
Protected Member Functions inherited from KviPackageIOEngine | |
void | hideProgressDialog () |
Hides the progress dialog. More... | |
bool | readError () |
Sets the last error as read error. More... | |
void | setLastError (const QString &szLastError) |
Sets the last error. More... | |
void | showProgressDialog (const QString &szCaption, int iTotalSteps) |
Shows the progress dialog. More... | |
bool | updateProgress (int iProgress, const QString &szLabel) |
Updates the progress dialog. More... | |
bool | writeError () |
Sets the last error as write error. More... | |
This class is used to create KVIrc package files.
You simply instantiate it, add some info fields, add some files and then call pack().
KviPackageWriter::KviPackageWriter | ( | ) |
Creates the package writer object.
References m_p, KviPackageWriterPrivate::pDataFields, and KviPointerList< T >::setAutoDelete().
|
virtual |
Destroys the object.
References m_p, and KviPackageWriterPrivate::pDataFields.
bool KviPackageWriter::addDirectory | ( | const QString & | szLocalDirectoryName, |
const QString & | szTargetDirectoryPrefix, | ||
kvi_u32_t | uAddFileFlags = 0 |
||
) |
Adds a directory to the package.
szLocalDirectoryName | The source directory |
szTargetDirectoryPrefix | The destination directory |
uAddFileFlags | The flags of the directory |
References addFileInternal(), d, KviQString::ensureLastCharIs(), KviQString::equalCS(), FollowSymLinks, j, and KVI_PATH_SEPARATOR_CHAR.
Referenced by AddonFunctions::pack(), and ThemeFunctions::packageThemes().
bool KviPackageWriter::addFile | ( | const QString & | szLocalFileName, |
const QString & | szTargetFileName, | ||
kvi_u32_t | uAddFileFlags = 0 |
||
) |
Adds a file to the package.
The file must be specified as absolute local path and as target path relative to the KVIrc local directory. This is a shortcut to addFileInternal() ... more ?
szLocalFileName | The source file |
szTargetFileName | The destination file |
uAddFileFlags | The flags of the file |
References addFileInternal().
Referenced by AddonFunctions::pack().
|
private |
Adds a file to the package.
This is the real addFile() function
fi | THe information of the file |
szLocalFileName | The source file |
szTargetFileName | The destination file |
uAddFileFlags | The flags of the file |
References KviPointerList< T >::append(), f, FollowSymLinks, KVI_PACKAGE_DATAFIELD_TYPE_FILE, KviPackageWriterDataField::m_bFileAllowCompression, m_p, KviPackageWriterDataField::m_szFileLocalName, KviPackageWriterDataField::m_szFileTargetName, KviPackageWriterDataField::m_uType, NoCompression, and KviPackageWriterPrivate::pDataFields.
Referenced by addDirectory(), and addFile().
void KviPackageWriter::addInfoField | ( | const QString & | szName, |
const QString & | szValue | ||
) |
Adds an info field as a name=value pair.
szName | The name of the info field |
szValue | The value of the info field |
References KviPointerHashTable< Key, T >::replace(), and KviPackageIOEngine::stringInfoFields().
Referenced by AddonFunctions::pack(), and ThemeFunctions::packageThemes().
void KviPackageWriter::addInfoField | ( | const QString & | szName, |
QByteArray * | pArray | ||
) |
Adds an info field as a name=value pair.
szName | The name of the info field |
pArray | The value of the info field |
References KviPackageIOEngine::binaryInfoFields(), and KviPointerHashTable< Key, T >::replace().
bool KviPackageWriter::pack | ( | const QString & | szFileName, |
kvi_u32_t | uPackFlags = 0 |
||
) |
Attempts to pack everything and store it as the specified file.
This is a shortcut to packInternal() hiding the progress dialog There is no mandatory extension but you should use KVI_FILEEXTENSION_THEMEPACKAGE for themes and KVI_FILEEXTENSION_ADDONPACKAGE for addons. See kvi_fileextension.h
szFileName | The file name of the package |
uPackFlags | The flags of the package |
References __tr2qs, KviPackageIOEngine::hideProgressDialog(), KviPackageWriterPrivate::iCurrentProgress, m_p, NoProgressDialog, packInternal(), KviPackageIOEngine::showProgressDialog(), and KviPackageIOEngine::updateProgress().
Referenced by AddonFunctions::pack(), and ThemeFunctions::packageThemes().
|
private |
Attempts to pack everything and store it as the specified file.
This is the real pack() function
pFile | The source file package |
pDataField | The data field for the package |
References __tr2qs, BUFFER_SIZE, KviPackageWriterPrivate::iCurrentProgress, kvi_file_offset_t, KVI_PACKAGE_DATAFIELD_FLAG_FILE_DEFLATE, KviPackageWriterDataField::m_bFileAllowCompression, m_p, KviPackageWriterDataField::m_szFileLocalName, KviPackageWriterDataField::m_szFileTargetName, KviPackageWriterDataField::m_uWrittenFieldLength, KviPackageIOEngine::readError(), KviFile::save(), KviPackageIOEngine::setLastError(), KviPackageIOEngine::updateProgress(), and KviPackageIOEngine::writeError().
Referenced by packInternal().
|
private |
Attempts to pack everything and store it as the specified file.
This is a shortcut to packFile() performing some checks
szFileName | The file name of the package |
uPackFlags | The flags of the package |
References __tr2qs, KviPackageIOEngine::binaryInfoFields(), KviPointerHashTable< Key, T >::count(), KviPointerList< T >::count(), KviPointerHashTableIterator< Key, T >::current(), KviPointerHashTableIterator< Key, T >::currentKey(), f, KviPointerList< T >::first(), KviPackageWriterPrivate::iCurrentProgress, kvi_file_offset_t, KVI_PACKAGE_DATAFIELD_TYPE_FILE, KVI_PACKAGE_INFOFIELD_TYPE_BINARYBUFFER, KVI_PACKAGE_INFOFIELD_TYPE_STRING, m_p, KviPointerList< T >::next(), packFile(), KviPackageWriterPrivate::pDataFields, s, KviFile::save(), KviPackageIOEngine::setLastError(), KviPackageIOEngine::stringInfoFields(), KviPackageIOEngine::updateProgress(), and KviPackageIOEngine::writeError().
Referenced by pack().
|
private |
Hidden private data
Referenced by addFileInternal(), KviPackageWriter(), pack(), packFile(), packInternal(), and ~KviPackageWriter().