recursive archive reading

David Faure faure at kde.org
Sun Apr 9 22:30:14 BST 2006


On Thursday 06 April 2006 14:22, Jos van den Oever wrote:
> 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. 
Not really since KIO's async and QAbstractFileEngine is sync, but ok :)

> It follows the backend for QFile and QDirectory. Now 
> QFile file("/tmp/code.tar.gz/src/main.cpp")
> will open the file main.cpp in the archive code.tar.gz for reading.
This sounds good. This solution for nested archives allows direct seeks (unlike 
the old idea of ioslave chaining), which is good for performance.
The path above is much like what kio_tar (the kioslave used for tar:/, zip:/ and ar:/) does 
(except that it doesn't support archive nesting at the moment).
Well kio_tar uses tar:/tmp/code.tar.gz/src/main.cpp, but it's the same idea of course.
I guess it makes sense to keep using a special protocol for it, because in some cases
applications want /tmp/code.tar.gz to be a file, and in some other cases (e.g. the directory
tree in konqueror), /tmp/code.tar.gz is seen like a directory that can be listed. So we could
keep the idea of "an optional redirection from file:///tmp/code.tar.gz to tar:///tmp/code.tar.gz"
as already implemented.

> QDir dir("/tmp/code.tar.gz");
> will allow you to list the entries in the archive.
Yes, but the question is whether QFileInfo says isDir or isFile. If yes, then it might become
impossible to open it as a file (e.g. for ark), depending on application logic.
This is why I think it should be done only from kio_tar.

> The code for this magic currently resides in
> http://websvn.kde.org/branches/work/kde4/playground/libs/archivereader/
Oh, this doesn't use KArchive but reimplements the support for Zip etc.?
How about porting it to KArchive? Well, that's almost like a rewrite except for the qt-file-engine
part of it. KArchive already has the notion of "input stream" since it can read from a QIODevice.

> 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.

IMHO the first step would be to use KArchive as the backend, since that 
one has a fully debugged tar/zip/ar/... implementation.

Then one could look into making kio_tar able to read nested archives this way.

But in fact a real solution, for being able to read from archives in all apps and
not just when opening the archive in konqueror first (to get the tar: or zip: protocol),
would be the QFSFileEngine solution indeed, if the issue of "is foo.tgz a file or a 
directory" is solved somehow. But I don't know how it should be solved.
In KFileDialog, when clicking on foo.tar.gz, how would we know if the user means
"I want to select this archive as a whole", or "I want to enter this archive as a directory
in order to select a file inside it". In directory tree views there is no problem
(regular files don't appear anyway), but in iconviews it's more tricky.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).





More information about the kde-core-devel mailing list