mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Fix handling of .zips files
This commit is contained in:
parent
d9e6c812fc
commit
9beaf862e8
|
@ -60,6 +60,9 @@ bool SplitFile::open( QFile::OpenMode mode )
|
||||||
|
|
||||||
bool SplitFile::seek( quint64 pos )
|
bool SplitFile::seek( quint64 pos )
|
||||||
{
|
{
|
||||||
|
if( offsets.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
int fileNom;
|
int fileNom;
|
||||||
|
|
||||||
for( fileNom = 0; fileNom < offsets.size() - 1; fileNom++ )
|
for( fileNom = 0; fileNom < offsets.size() - 1; fileNom++ )
|
||||||
|
@ -74,6 +77,9 @@ bool SplitFile::seek( quint64 pos )
|
||||||
|
|
||||||
qint64 SplitFile::read( char *data, qint64 maxSize )
|
qint64 SplitFile::read( char *data, qint64 maxSize )
|
||||||
{
|
{
|
||||||
|
if( offsets.isEmpty() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
quint64 bytesReaded = 0;
|
quint64 bytesReaded = 0;
|
||||||
for( int i = currentFile; i < files.size(); i++ )
|
for( int i = currentFile; i < files.size(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -117,7 +123,7 @@ bool SplitFile::getChar( char *c )
|
||||||
|
|
||||||
qint64 SplitFile::pos() const
|
qint64 SplitFile::pos() const
|
||||||
{
|
{
|
||||||
if( files.isEmpty() )
|
if( offsets.isEmpty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return offsets.at( currentFile ) + files.at( currentFile )->pos();
|
return offsets.at( currentFile ) + files.at( currentFile )->pos();
|
||||||
|
|
11
zipfile.cc
11
zipfile.cc
|
@ -200,8 +200,17 @@ SplitZipFile::SplitZipFile( const QString & name )
|
||||||
|
|
||||||
void SplitZipFile::setFileName( const QString & name )
|
void SplitZipFile::setFileName( const QString & name )
|
||||||
{
|
{
|
||||||
if( !name.toLower().endsWith( ".zip" ) )
|
{
|
||||||
|
QString lname = name.toLower();
|
||||||
|
if( lname.endsWith( ".zips" ) )
|
||||||
|
{
|
||||||
|
appendFile( name );
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !lname.endsWith( ".zip" ) )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( QFileInfo( name ).isFile() )
|
if( QFileInfo( name ).isFile() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue