Who have Qt Wrapper for bzip2 ?
Who have Qt Wrapper for bzip2 ?
have a look at QuaZIP.
that just for zip. And for unzip is very slow on Linux.
Sorry Lykurg, but you are wrong. ZLib and BZip2 are different algorithms and uses different libraries.
Wirasto, as far as I know there is no BZip2 wrapper for Qt. But you can use zlib wrapper as a pattern or take bzip2 source code and reimplement the algorithm as Qt class by yourself. The only question - please share that I think a lot of people will appreciate that.
Regards,
-- tanuki
I think Lykurg meant "Use ZIP which does have a Qt wrapper and used in many programs, or write your own wrapper for bzip". Heck, you could probably use most of the wrapper of zip for bzip, as they share a lot in common (apart from the obvious things like the actual algorithm, which will be in a seperate library anyway)
this code form QuaZIP unzip sample
Qt Code:
// Slow like hell (on GNU/Linux at least), but it is not my fault. // Not ZIP/UNZIP package's fault either. // The slowest thing here is out.putChar(c). while(file.getChar(&c)) out.putChar(c);To copy to clipboard, switch view to plain text mode
How to change that code with Qt function ?
Use QByteArray and block operations.How to change that code with Qt function ?
First thing I'd say is: WHY is it written like that? The comment seems to imply there was no alternative, which I find suprising. Are 'file' and 'out' internal classes for some reason? In which case you probably can't change it easily. If it's standard i/o however, then I'd find the end and read it in blocks which would be MUCH faster.
I'd probably use:
QByteArray QIODevice::read ( qint64 maxSize )
write ( const QByteArray & byteArray )
I'm assuming "file" is a zip device and there is a chance it needs to be read byte by byte. In that case the only thing you can do is read byte by byte but then write block by block. If "out" is a zip device then of course you need to reverse what I've written here (i.e. read block by block and write byte by byte).
Read byte by byte and write block by block ? I don't get what is your mean. Can you give me a sample code how to do that ?
Read into a QByteArray, and then write() that entire byte array when the size is >= a certain amount.
Bookmarks