Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:39:53+00:00 2026-06-14T19:39:53+00:00

I read documentation and post about uncompressing ZIP files but I’ve additional questions. I

  • 0

I read documentation and post about uncompressing ZIP files but I’ve additional questions.
I need to uncompress zip file in Qt. That is XML file compressed with gzip.
I know that qUnCompress can uncompressing zip files prepared with ZLIB and ZLIB has diffrent header than GZIP.

As i read in documentation:

Note: If you want to use this function to uncompress external data that was compressed using zlib, you first need to prepend a four byte header to the byte array containing the data. The header must contain the expected length (in bytes) of the uncompressed data, expressed as an unsigned, big-endian, 32-bit integer.

Is that means that I have to put at the beginning only length (bigendian) and than compressed data ?
I did it but I have an error from qUncompress function:

qUncompress: Z_DATA_ERROR: Input data is corrupted

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:39:55+00:00Added an answer on June 14, 2026 at 7:39 pm

    You need to write you own gUncompress() function using either zlib, or some other library, that implements the DEFLATE algorithm. I personally prefer miniz:

    http://code.google.com/p/miniz/

    Here’s some code for you:

    #include <stdexcept>
    
    #include <QtCore>
    
    #ifndef TINFL_HEADER_FILE_ONLY
    # define TINFL_HEADER_FILE_ONLY
    #endif // TINFL_HEADER_FILE_ONLY
    extern "C" {
    # include "tinfl.h"
    }
    
    #include "guncompress.hpp"
    
    static tinfl_decompressor inflator;
    
    static QByteArray result(TINFL_LZ_DICT_SIZE, 0);
    
    //////////////////////////////////////////////////////////////////////////////
    QByteArray gUncompress(QByteArray const& data)
    {
      mz_uint8 const* inPtr(reinterpret_cast<mz_uint8 const*>(data.data()) + 10);
    
      tinfl_init(&inflator);
    
      size_t inAvail(data.size());
      size_t outTotal(0);
    
      tinfl_status ret;
    
      do
      {
        size_t inSize(inAvail);
        size_t outSize(result.size() - outTotal);
    
        ret = tinfl_decompress(&inflator,
          inPtr,
          &inSize,
          reinterpret_cast<mz_uint8*>(result.data()),
          reinterpret_cast<mz_uint8*>(result.data()) + outTotal,
          &outSize,
          0 
          );
    
        switch (ret)
        {
          case TINFL_STATUS_HAS_MORE_OUTPUT:
            inAvail -= inSize;
            inPtr += inSize;
    
            result.resize(2 * result.size());
    
          case TINFL_STATUS_DONE:
            outTotal += outSize;
            break;
    
          default:
            throw std::runtime_error("error decompressing gzipped content");
        }
      }
      while (TINFL_STATUS_DONE != ret);
    
      return QByteArray::fromRawData(result.data(), outTotal);
    }
    

    Also note that zip files and gzip files do not share the same format. Zip files need to be handled differently, as they contain a directory of files they contain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read all the documentation about hooks , similar questions and a lot of
I need to optimize the read/write count for a POST request that I'm using.
I have read documentation for functions such as values and define-values that return and
I read the documentation, but I did not understand what is the purpose of
I have read the documentation and searched all over but I can't find how
I have read the documentation that states that "given the type of the enum,
I have read the documentation ( http://dev.mysql.com/doc/refman/5.1/en/partitioning.html ), but I would like, in your
The PHP documentation states that php://input can only be read once. In my application
I have read in HttpServlet documentation that A subclass of HttpServlet must override at
I read on the facebook documentation ( here ) that you can force a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.