Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to manage zip file
Forum Updated to NodeBB v4.3 + New Features

How to manage zip file

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 7 Posters 32.1k Views 6 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #12

    Hi,

    What do you have in QBABufferOut ?
    Are you sure it's opened correctly ?
    Why do you need BufferIn for ?

    And most important, what do you mean by does not seem to work? That's to vague to help you.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #13

      Please have a look at this sequence:

                                  QuaZipFile quaZip(QBABufferOut);                // (rapresents a zip archivie in ram).
                                  if (quaZip.open(QIODevice::ReadOnly)) {         // QIODevice::ReadOnly or someting else
                                      qDebug() << "ok";
                                  } else qDebug() << "error";                     // always error!!!!!!!!!!!!
      
      

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #14

        You have to open the QuaZip for decompression first:

            QBuffer storageBuff(&QBABufferOut);
            QuaZip zip(&storageBuff);
            if (!zip.open(QuaZip::mdUnzip))
                qDebug() << "error";
            QuaZipFile file(&zip);
            for (bool f = zip.goToFirstFile(); f; f = zip.goToNextFile()) {
                QuaZipFileInfo fileInfo;
                file.getFileInfo(&fileInfo);
                qDebug() << fileInfo.name;
                file.open(QIODevice::ReadOnly);
                
                qDebug() << "Content: " << file.readAll().toBase64();
                file.close();
            }
            zip.close();
        

        P.S.

        // (rapresents a zip archivie in ram).

        No it doesn't. As mentioned before QuaZipFile represent a file inside a zip archive, not the archive itself

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        4
        • mrdebugM Offline
          mrdebugM Offline
          mrdebug
          wrote on last edited by
          #15

          It works perfectly.
          Many thanks.

          Need programmers to hire?
          www.labcsp.com
          www.denisgottardello.it
          GMT+1
          Skype: mrdebug

          Ramkumar MohanR 1 Reply Last reply
          0
          • VRoninV VRonin

            The only answer is zlib, you just need to decide the flavour

            • QuaZIP (handles only .zip, wrapper around zlib)
            • KArchive (supports multiple compression formats, for zip it's a wrapper on zlib)
            • zlib if you don't mind C then you can use directly the reference library for zip files

            I personally use KArchive because it's already conveniently wrapped in a Qt style and it can rely on the support of KDE

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #16

            @VRonin said in How to manage zip file:

            QuaZIP

            Is there a license associated with the use of this? As I have a need for compressing large amounts of binary data that I need to transmit to remote clients.

            Kind Regards,
            Sy

            jsulmJ 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @VRonin said in How to manage zip file:

              QuaZIP

              Is there a license associated with the use of this? As I have a need for compressing large amounts of binary data that I need to transmit to remote clients.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #17

              @SPlatten said in How to manage zip file:

              Is there a license associated with the use of this?

              https://github.com/stachenov/quazip

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #18

                Thank you,

                Kind Regards,
                Sy

                artwawA 1 Reply Last reply
                0
                • SPlattenS SPlatten

                  Thank you,

                  artwawA Offline
                  artwawA Offline
                  artwaw
                  wrote on last edited by
                  #19

                  @SPlatten if both ends are in your software I'd suggest agains using 3rd party library. qCompress and qUncompress work just fine in that regard. My usual approach is to supply a header (using QDataStream) with checksum and whatever else is needed, then stream to it output from compression routine. Works sufficiently well, eliminates the need for another dependency.

                  For more information please re-read.

                  Kind Regards,
                  Artur

                  SPlattenS 1 Reply Last reply
                  2
                  • artwawA artwaw

                    @SPlatten if both ends are in your software I'd suggest agains using 3rd party library. qCompress and qUncompress work just fine in that regard. My usual approach is to supply a header (using QDataStream) with checksum and whatever else is needed, then stream to it output from compression routine. Works sufficiently well, eliminates the need for another dependency.

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #20

                    @artwaw , Thank you, I will have a look.

                    Kind Regards,
                    Sy

                    1 Reply Last reply
                    0
                    • mrdebugM mrdebug

                      It works perfectly.
                      Many thanks.

                      Ramkumar MohanR Offline
                      Ramkumar MohanR Offline
                      Ramkumar Mohan
                      wrote on last edited by
                      #21

                      @mrdebug Which file works properly in this?

                      1 Reply Last reply
                      0
                      • mrdebugM Offline
                        mrdebugM Offline
                        mrdebug
                        wrote on last edited by
                        #22

                        Hi, I'm working with zip files.

                        Need programmers to hire?
                        www.labcsp.com
                        www.denisgottardello.it
                        GMT+1
                        Skype: mrdebug

                        1 Reply Last reply
                        0
                        • jsulmJ jsulm referenced this topic on
                        • JonBJ JonB referenced this topic on
                        • M mpergand referenced this topic on

                        • Login

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