mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
fix: epwing case sensitive (#1093)
* fix: epwing folder name is casesensitive in Linux * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
98af55557e
commit
ccd04e0b51
|
@ -1187,13 +1187,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
QFileInfo info( fontSubName );
|
||||
if ( info.exists() && info.isFile() )
|
||||
dictFiles.push_back( fontSubName.toStdString() );
|
||||
else {
|
||||
//to make the subbook in different index.
|
||||
auto virtual_file = QString::fromStdString( mainDirectory ) + QDir::separator() + QString::number( sb );
|
||||
dictFiles.push_back( virtual_file.toStdString() );
|
||||
}
|
||||
|
||||
// Check if we need to rebuid the index
|
||||
// Check if we need to rebuild the index
|
||||
|
||||
string dictId = Dictionary::makeDictionaryId( dictFiles );
|
||||
|
||||
|
@ -1208,7 +1203,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
File::Class idx( indexFile, "wb" );
|
||||
|
||||
IdxHeader idxHeader;
|
||||
IdxHeader idxHeader{};
|
||||
|
||||
memset( &idxHeader, 0, sizeof( idxHeader ) );
|
||||
|
||||
|
|
|
@ -596,7 +596,36 @@ QString EpwingBook::getCurrentSubBookDirectory()
|
|||
throw exEbLibrary( error_string.toUtf8().data() );
|
||||
}
|
||||
|
||||
return QString::fromLocal8Bit( buffer );
|
||||
QString subDir = QString::fromLocal8Bit( buffer );
|
||||
|
||||
return repairSubBookDirectory( subDir );
|
||||
}
|
||||
|
||||
QString EpwingBook::repairSubBookDirectory( QString subBookDir )
|
||||
{
|
||||
char path[ EB_MAX_PATH_LENGTH + 1 ];
|
||||
EB_Error_Code error_code = eb_path( &book, path );
|
||||
if ( error_code != EB_SUCCESS )
|
||||
return subBookDir;
|
||||
|
||||
const QString & mainDirectory = QString::fromLocal8Bit( path );
|
||||
QDir mainDir( mainDirectory );
|
||||
QStringList allIdxFiles = mainDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks );
|
||||
|
||||
if ( allIdxFiles.contains( subBookDir ) ) {
|
||||
return subBookDir;
|
||||
}
|
||||
|
||||
qDebug() << "Epwing: can not found subbook directory,try to fix automatically, dir=>" << subBookDir;
|
||||
|
||||
for ( const auto & file : allIdxFiles ) {
|
||||
if ( file.compare( subBookDir, Qt::CaseInsensitive ) == 0 ) {
|
||||
qDebug() << "Epwing: found " << file;
|
||||
return file;
|
||||
}
|
||||
}
|
||||
//return original subbook directory
|
||||
return subBookDir;
|
||||
}
|
||||
|
||||
QString EpwingBook::makeFName( QString const & ext, int page, int offset ) const
|
||||
|
|
|
@ -239,6 +239,7 @@ public:
|
|||
bool getMatches( QString word, QVector< QString > & matches );
|
||||
|
||||
bool getArticlePos( QString word, QVector< int > & pages, QVector< int > & offsets );
|
||||
QString repairSubBookDirectory( QString subBookDir );
|
||||
};
|
||||
|
||||
struct EContainer
|
||||
|
|
Loading…
Reference in a new issue