I have some problem with archives library. I need send qbytearray to an archive class, and get it back as qbytearray of compressed data. The main reason - is that I need do decompress incoming message, because it was compressed before sending me.
And vice versa. The main problem, that I don't know how to use quazip for compress data represented by only qbytearray,and get result of compression back as qbytearrray? Сan someone give me useful example of compress decompress message by using quazip?
I did part for decompressing data from archive represented by qBytearray, please check me, see code below :
void Receiver::unzipFromQByteArray(QByteArray &_message)
{
QBuffer storageBuff(&_message);
QuaZip zip(&storageBuff);
if (!zip.open(QuaZip::mdUnzip))
qDebug() << "error";
QuaZipFile file(&zip);
for (bool f = zip.goToFirstFile(); f; f = zip.goToNextFile()) {
QuaZipFileInfo fileInfo;
file.getFileInfo(&fileInfo);
qDebug() << fileInfo.name;
file.open(QIODevice::ReadOnly);
qDebug() << "get data : " << file.readAll().toBase64();
file.close();
}
zip.close()
Please check my code, and help me with writing part for pack to zip rawdata and if I'm not correct with decompression pls, correct me.