[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    recursive archive reading
From:       "Jos van den Oever" <jvdoever () gmail ! com>
Date:       2006-04-06 12:22:19
Message-ID: c2dbc4260604060522oa25d756ua6805d860f5c3868 () mail ! gmail ! com
[Download RAW message or body]

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 implementatio=
n
was much too slow. So I implemented some classes based on the java class bu=
t
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 acros=
s
the class QAbstractFileEngine in Qt 4.1. This class has functionality
similar to that in kio. It follows the backend for QFile and QDirectory. No=
w
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:

#include <archivestreamhandler.h>

and later in the context where you would like to read the archives:

ArchiveStreamEngine yournameofchoice;

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.
For example:

QFile file("/tmp/code.tar.gz/src/main.cpp")

will open the file main.cpp in the archive code.tar.gz for reading.

QDir dir("/tmp/code.tar.gz");

will allow you to list the entries in the archive.

And recursive access works too:

QFile file("/tmp/code.tar.gz/data/test.zip/unitinput.txt");

will open the file in the zip archive in the tar.gz file.

The code for this magic currently resides in
http://websvn.kde.org/branches/work/kde4/playground/libs/archivereader/

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.

Best regards,
Jos

[Attachment #3 (text/html)]

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 &lt;archivestreamhandler.h&gt;<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&nbsp; if the mentioned file \
is an archive.<br>For example: <br><br>QFile \
file(&quot;/tmp/code.tar.gz/src/main.cpp&quot;)<br><br>will open the file main.cpp in \
the archive code.tar.gz for reading.<br><br>QDir \
dir(&quot;/tmp/code.tar.gz&quot;);<br><br>will allow you to list the entries in the \
archive. <br><br>And recursive access works too:<br><br>QFile \
file(&quot;/tmp/code.tar.gz/data/test.zip/unitinput.txt&quot;);<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/archiver \
eader/">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>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic