0

Im using qUncompress to unzip a file that was originally zipped in Mac OS X (right click -> compress)

My code looks like:

        QString location = "/path/to/file/";
        QFile infile(location + "file.zip");
        QFile outfile(location + "file.app");
        infile.open(QIODevice::ReadOnly);
        outfile.open(QIODevice::WriteOnly);
        QByteArray uncompressedData = infile.readAll();
        QByteArray compressedData = qUncompress(uncompressedData);
        outfile.write(compressedData);
        infile.close();
        outfile.close();

However I am getting this error:

qUncompress: Z_DATA_ERROR: Input data is corrupted

Any ideas what could be wrong?

user3490755
  • 955
  • 2
  • 15
  • 33

1 Answers1

0

@Dmitry Sazonov is correct. qUncompress is designed for how Qt stores media data. It stores media data in a compressed form in strings in the binary, where qUncompress is used during execution. It won't help you on .zip files.

According to the zlib web FAQ, zip files cannot be inflated by zlib. The author of that FAQ recommends minizip.

Link: http://www.zlib.net/zlib_faq.html#faq11

macetw
  • 1,640
  • 1
  • 17
  • 26