recursive archive reading
Jos van den Oever
jvdoever at gmail.com
Thu Apr 6 13:22:19 BST 2006
Hello dear KDE developers,
A serious limitation of KDE's kio plugins is that there is currently no way
of reading archives that are stored within other archives. I needed to
overcome this limitation when I wanted to calculate MD5 sums for all my
files so that I fix the mess that is my personal data.
At first I wanted to use java for this code because it has the excellent
InputStream class with archive reading derivatives. This java implementation
was much too slow. So I implemented some classes based on the java class but
with added speed because of the faster C++ language but also because I'm
handling buffers differently. Instead of writing into a caller-provided
buffer, the caller retrieves a pointer to the data along with a number
specifying the number of fresh bytes available.
When thinking about a client to read the files after indexing, I came across
the class QAbstractFileEngine in Qt 4.1. This class has functionality
similar to that in kio. It follows the backend for QFile and QDirectory. Now
I've implemented a library that uses the mentioned streaming classes to
provide every Qt 4.1 app with the ability to read nested archives. All you
need to do for this is to add two lines to your code:
and later in the context where you would like to read the archives:
And that's all. Now every call to QFile or QDirectory will try to see if
there's an archive in the mentioned file or if the mentioned file is an
will open the file main.cpp in the archive code.tar.gz for reading.
will allow you to list the entries in the archive.
And recursive access works too:
will open the file in the zip archive in the tar.gz file.
The code for this magic currently resides in
With this mail I wanted to announce this code and start a discussion about
what the best way is to add this functionality to KDE4. As I've
demonstrated, it's already easy to use the code in this way, but how would
this fit together with the existing KIO framework.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the kde-core-devel