Commit 211f082f authored by Pino Toscano's avatar Pino Toscano

Scan recursively for images in CBZ archives.

BUG: 178029

svn path=/trunk/KDE/kdegraphics/okular/; revision=899134
parent e8804c18
......@@ -20,6 +20,19 @@
using namespace ComicBook;
static void imagesInArchive( const QString &prefix, const KArchiveDirectory* dir, QStringList *entries )
{
Q_FOREACH ( const QString &entry, dir->entries() ) {
const KArchiveEntry *e = dir->entry( entry );
if ( e->isDirectory() ) {
imagesInArchive( prefix + entry + "/", static_cast<const KArchiveDirectory*>( e ), entries );
} else if ( e->isFile() ) {
entries->append( prefix + entry );
}
}
}
Document::Document()
: mUnrar( 0 ), mZip( 0 )
{
......@@ -57,15 +70,9 @@ bool Document::open( const QString &fileName )
}
mZipDir = const_cast<KArchiveDirectory*>( directory );
QStringList entries = directory->entries();
if ( entries.count() == 1 ) {
// seems to be a nested directory
const KArchiveEntry *entry = directory->entry( entries[ 0 ] );
if ( entry->isDirectory() ) {
entries = static_cast<const KArchiveDirectory*>( entry )->entries();
mZipDir = const_cast<KArchiveDirectory*>( static_cast<const KArchiveDirectory*>( entry ) );
}
}
QStringList entries;
imagesInArchive( QString(), mZipDir, &entries );
extractImageFiles( entries );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment