xps: split loadFile() in loadEntry() + loadFile()

loadEntry() retains the main entry loading logic (with the case insensitivity),
return just generic KArchiveEntry pointers
loadFile() just calls loadEntry(), returning the result if the entry is a file
remotes/origin/KDE/4.7
Pino Toscano 15 years ago
parent fbe0c0764f
commit a4ba73feb1
  1. 13
      generators/xps/generator_xps.cpp

@ -535,10 +535,10 @@ static QByteArray readFileOrDirectoryParts( const KArchiveEntry *entry, QString
/**
Load the resource \p fileName from the specified \p archive using the case sensitivity \p cs
*/
static const KZipFileEntry* loadFile( KZip *archive, const QString &fileName, Qt::CaseSensitivity cs )
static const KArchiveEntry* loadEntry( KZip *archive, const QString &fileName, Qt::CaseSensitivity cs )
{
// first attempt: loading the entry straight as requested
const KZipFileEntry* entry = static_cast< const KZipFileEntry * >( archive->directory()->entry( fileName ) );
const KArchiveEntry* entry = archive->directory()->entry( fileName );
// in case sensitive mode, or if we actually found something, return what we found
if ( cs == Qt::CaseSensitive || entry ) {
return entry;
@ -562,14 +562,19 @@ static const KZipFileEntry* loadFile( KZip *archive, const QString &fileName, Qt
qSort( relEntries );
Q_FOREACH ( const QString &relEntry, relEntries ) {
if ( relEntry.compare( entryName, Qt::CaseInsensitive ) == 0 ) {
const KArchiveEntry* ee = relDir->entry( relEntry );
return ee->isFile() ? static_cast< const KZipFileEntry * >( ee ) : 0;
return relDir->entry( relEntry );
}
}
}
return 0;
}
static const KZipFileEntry* loadFile( KZip *archive, const QString &fileName, Qt::CaseSensitivity cs )
{
const KArchiveEntry *entry = loadEntry( archive, fileName, cs );
return entry->isFile() ? static_cast< const KZipFileEntry * >( entry ) : 0;
}
/**
\return The name of a resource from the \p fileName
*/

Loading…
Cancel
Save