PDA

View Full Version : How to archieve files with QtIOCompressor?



TorAn
10th November 2010, 23:08
I can't figure out how to create an archieve of several files using QtIOCompressor (Qt solution). It is quite clear how to store bytearray, and samples also show how to extract the files from the archieve.

But it is unclear how to store files in the archieve.

Please mention here if there is another way of creating archieves in Qt. The only thing I found is QtIOCompressor, and for extracting files it does what I need.

Any help/hints will be greatly appreciated. Thanks.

Vadim
11th November 2010, 00:27
That something you would need to implement yourself of use a 3rd party program. There is plenty of those.

TorAn
11th November 2010, 00:55
What's confusing is that "qt solution" provides the way to read the zip archive and extract files from it, but is silent on creating the archive from files. I tried reading a standard zip file and it worked. I can store the files in the archive just by doing steps in reverse, like the example shows, so "rolling your own" is not a problem. I just expected "qt solution" to be a solution for these basic operations of extracting/storing files.

ChrisW67
11th November 2010, 05:02
The QtIOCompressor class can read and write streams written using the compression methods supported by zlib, i.e. what gzip uses and not PKZIP. Zlib compresses a single stream and normally you would use some other method to catenate multiple files inside the stream, e.g. tar, so that multiple files can be extracted after the stream is decompressed at the other end.

As the docs (http://doc.trolltech.com/solutions/4/qtiocompressor/qtiocompressor.html) say, the compressor can produce a compression compatible with what PKZIP does to a single file within an archive but it does not produce the PKZIP internal file indexes: that is up to you if you want to read/write PKZIP files. The "ziplist" example referred to in the docs should give you help (if it is part of the sources).

TorAn
11th November 2010, 13:02
Yes, the sample shows the way. At the same time it is confusing from the standpoint of a developer who is seeing the reading sample, but can't find writing sample. That led to my question in the first place, I assumed that I am missing something. It turns out that I am not. Reading sample for multiple files exists, but writing multiple files is left as an "excersise" for the developer, although QtIOCompressor is presented as a "Qt Solution". I find it strange.