×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    How to uncompress zip file in QT ???

    Recently i am developing an application for my N9 which has to download a zip file from the server(because the sever only provide the zip format file),
    thus ,i need to uncompress the zip file to its real file and use it.
    I dont know how to uncompress zip file by QT,I need some help ,please??
    Can anyone get some useful source code that related to uncompress zip file on N9 ???
    Thanks ,sorry for my poor english.
    I need some source code or project that can be fully used in N9,Thanks.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: How to uncompress zip file in QT ???

    have you tried searching anything yet ?
    I got two links with very simple search:
    http://www.qtforum.org/article/35737/zip-and-unzip.html
    http://stackoverflow.com/questions/4...ip-unzip-files

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: How to uncompress zip file in QT ???

    I've searched a lot ,but havent found specially userful infomation
    http://www.qtforum.org/article/35737/zip-and-unzip.html This article is useless for it is not for zip,i 've tried.
    Thanks,but i need some more useful methods .

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: How to uncompress zip file in QT ???

    Based on the ,9 appearing as argument in qCompress, it is probably safe to assume that qCompress-qUncompress are about deflating a single binary blob.
    You can use it for extracting .zip files, but the compressed binary blob has to be read manually. The format specification is here: http://www.pkware.com/documents/casestudies/APPNOTE.TXT
    The approach is simple: read and decode the fixed, 30 bytes header, then you will know the lenght of filename, extra data and actual file data (use "compressed size" here), so read them too, and you can hopefully decompress the file data with qUncompress. Then you can check if the uncompressed size is really the expected one, and you may also check crc. Apparently these fields are also repeated after the file data, so read/skip them.
    And repeat for the next file, until something unexpected (when checking the header, its first 4 bytes is a magic number which is different for the trailing part of the .zip file) is encountered.

  5. #5
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: How to uncompress zip file in QT ???

    But how i could write it in coding?
    Such code like this is wrong
    Code:
        QFile infile("E:/tmp/11.zip");
            QFile outfile("E:/tmp/train");
            infile.open(QIODevice::ReadOnly);
            outfile.open(QIODevice::WriteOnly);
            QByteArray uncompressedData = infile.readAll();
            QByteArray compressedData = qUncompress(uncompressedData);
            outfile.write(compressedData);
            infile.close();
            outfile.close();

  6. #6
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: How to uncompress zip file in QT ???

    Can you please give me some simple example?
    My zip file contains only 1 file in it.
    I want to have the simplest wat to uncompress it ,thanks!
    Quote Originally Posted by wizard_hu_ View Post
    Based on the ,9 appearing as argument in qCompress, it is probably safe to assume that qCompress-qUncompress are about GZip-ing a single binary blob.
    You can use it for extracting .zip files, but the compressed binary blob has to be read manually. The format specification is here: http://www.pkware.com/documents/casestudies/APPNOTE.TXT
    The approach is simple: read and decode the fixed, 30 bytes header, then you will know the lenght of filename, extra data and actual file data (use "compressed size" here), so read them too, and you can hopefully decompress the file data with qUncompress. Then you can check if the uncompressed size is really the expected one, and you may also check crc. Apparently these fields are also repeated after the file data, so read/skip them.
    And repeat for the next file, until something unexpected (when checking the header, its first 4 bytes is a magic number which is different for the trailing part of the .zip file) is encountered.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: How to uncompress zip file in QT ???

    I simply do not know Qt, just commented here because I noticed the thread on the main page.
    The pseudo code is just reading a "local file header" (4.3.7 in the referred documentation), then the compressed blob.
    - reading a 4-byte integer first and checking if it is 0x04034b50 is generally a good idea
    - skip 14 bytes as a minimal approach
    - read a 4-byte integer as compressed size
    - read a 4-byte integer as uncompressed size
    - read a 2-byte integer as length for filename
    - read a 2-byte integer as length for extra data
    - read or skip the filename (with the specified length)
    - skip the extra data (with the specified length)
    - read the file data (compressed size)
    - qUncompress the file data
    - check if the result has the same size as "uncompressed size"

  8. #8
    Registered User
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,571

    Re: How to uncompress zip file in QT ???

    Consider trying http://quazip.sourceforge.net/ - it states support for some other Linux platforms.

  9. #9
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: How to uncompress zip file in QT ???

    I've searched this project several days before,but still dont know how to use it in N9 developing.
    I tried several times,Always fail in uncompressing zip file.

  10. #10
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: How to uncompress zip file in QT ???

    I succeeded in uncompressing zip file.
    Just try to include quazip'pri file into you project is OK
    Then use the Jlcomress class ,very essy and fast!

  11. #11
    Registered User
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,571

    Re: How to uncompress zip file in QT ???

    Quote Originally Posted by rhythmkay View Post
    I succeeded in uncompressing zip file.
    Just try to include quazip'pri file into you project is OK
    Then use the Jlcomress class ,very essy and fast!
    Great to hear. I had the same result on Symbian. The guy running this is really good - even did some work to make sure that for Symbian it would build against the SDK headers.

Similar Threads

  1. How to build uncompress executable for 9.0?
    By swapnil_mahajan in forum Symbian
    Replies: 4
    Last Post: 2009-05-08, 12:01
  2. Replies: 2
    Last Post: 2007-08-31, 09:56
  3. Replies: 0
    Last Post: 2007-08-31, 08:58
  4. Replies: 0
    Last Post: 2005-10-21, 20:08
  5. reading text file from a jar file -> file not found!
    By iecomdev in forum Mobile Java General
    Replies: 1
    Last Post: 2002-09-30, 12:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×