Hello dear KDE developers,<br><br>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.
<br><br>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.
<br><br>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:<br><br>#include <archivestreamhandler.h><br><br>and later in the context where you would like to read the archives:
<br><br>ArchiveStreamEngine yournameofchoice;<br><br>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 archive.<br>For example:
<br><br>QFile file("/tmp/code.tar.gz/src/main.cpp")<br><br>will open the file main.cpp in the archive code.tar.gz for reading.<br><br>QDir dir("/tmp/code.tar.gz");<br><br>will allow you to list the entries in the archive.
<br><br>And recursive access works too:<br><br>QFile file("/tmp/code.tar.gz/data/test.zip/unitinput.txt");<br><br>will open the file in the zip archive in the tar.gz file.<br><br>The code for this magic currently resides in
<a href="http://websvn.kde.org/branches/work/kde4/playground/libs/archivereader/">http://websvn.kde.org/branches/work/kde4/playground/libs/archivereader/</a><br><br>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.
<br><br>Best regards,<br>Jos<br><br><br><br>