2

This is my c++ code:

#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QFile>
#include <QByteArray>

QByteArray UnZip (QString zipfilename)
{
    QFile infile(zipfilename);
    infile.open(QIODevice::ReadOnly);
    //QByteArray uncompressedData = infile.readAll();
    QByteArray uncompressedData = qUncompress(infile.readAll());
    infile.close();

    return uncompressedData;
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    //QString path = "/Users/davide/Desktop/fh8RkbUf";
    QString path = "/Users/davide/Desktop/test";

    QByteArray data = UnZip(path);

    qDebug() << "message";

    return a.exec();
}

; that returns qUncompress: Z_DATA_ERROR: Input data is corrupted

However, data should be zlib compressed and php's gzuncompress($data) works fine.

Also, cat file | uncompress returns errors.

The code php side is

$data = gzcompress($data, 6);
$success = file_put_contents($file, $data);
cedivad
  • 2,544
  • 6
  • 32
  • 41
  • http://stackoverflow.com/questions/2690328/qt-quncompress-gzip-data – hakre Dec 26 '11 at 21:35
  • as far as i understand, the goal there whas to uncompress gzip data. I have zlib data here. (maybe i'm wrong) – cedivad Dec 26 '11 at 21:40
  • 1
    I have no QT here, I read it that PHP's [`gzcompress`](http://php.net/gzcompress) *is* ZLIB (not GZ). – hakre Dec 26 '11 at 21:43
  • Yes, so it should be compatible with qUncompress, reading the documentation. Don't know. – cedivad Dec 26 '11 at 21:47
  • 1
    @cedivad: Try uncompressing the file using `python` (there's a handy `zlib` standard module) to see if it's a corrupted file. `compress` and `uncompress` use only LZ77 encoding, not the zlib format, so it's normal that you get an error there. – Cameron Dec 27 '11 at 03:39

0 Answers0