Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. How to use QuaZIP for zipping a file
Forum Updated to NodeBB v4.3 + New Features

How to use QuaZIP for zipping a file

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 7.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    croussou
    wrote on last edited by
    #1

    I am currently using a simple code for generating a .zip file containing a .txt file.

    @QCoreApplication a(argc, argv);

    QFile input("/Users/croussou_dm4/Desktop/text1.txt");
    QFile output("/Users/croussou_dm4/Desktop/text1.zip");
    
    input.open(QIODevice::ReadOnly);
    output.open(QIODevice::WriteOnly);
    
    QByteArray uncompressedData = input.readAll();
    QByteArray compressedData = qCompress(uncompressedData);
    
    output.write(compressedData);
    
    input.close();
    output.close();
    
    return a.exec();@
    

    I have read and tested that the file cannot be opened with any unzipping program because it is missing relevant header information as well as the "magic number" (explain?). Several sources indicate that QuaZIP seems to do the work, but I don't understand exactly how to use it...

    Any ideas and suggestions would be greatly appreciated.

    Thank you in advance.

    Regards,

    croussou

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      A compressed file, an archive and a .zip file are three different things:

      • a compressed file is a plain file converted into a different format with a lesser size,
      • an archive is a set of uncompressed files packed in a single uncompressed file,
      • a .zip file is a compressed archive, using a specific archive and compression format.

      You cannot create one and treat it as another.

      QuaZip allows you to handle .zip files. It is documented and comes with some examples. In addition, there are multiple threads on the forums on QuaZip.

      Is there a specific problem you've encountered?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        croussou
        wrote on last edited by
        #3

        Thank you for your prompt reply.

        I am just searching for a solid, simple example to start. Because at the moment I have only an abstract idea what I can achieve with QuaZIP. I just want to save a .txt file in a .zip, nothing else.

        Regards,

        croussou

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved