mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-03 15:34:06 +00:00
When searching for resource files, allow them to be not only in the dictionary
directory, but also in the dictionary-name.files/ subdirectory.
This commit is contained in:
parent
e9799ba248
commit
1a5a4daa52
45
src/dsl.cc
45
src/dsl.cc
|
@ -380,7 +380,18 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
|
||||
try
|
||||
{
|
||||
File::Class f( n, "r" );
|
||||
try
|
||||
{
|
||||
File::Class f( n, "rb" );
|
||||
}
|
||||
catch( File::exCantOpen & )
|
||||
{
|
||||
n = getDictionaryFilenames()[ 0 ] + ".files" +
|
||||
FsEncoding::separator() +
|
||||
FsEncoding::encode( filename );
|
||||
|
||||
File::Class f( n, "rb" );
|
||||
}
|
||||
|
||||
search = false;
|
||||
}
|
||||
|
@ -589,6 +600,19 @@ string DslDictionary::getArticle( wstring const & word,
|
|||
return result;
|
||||
}
|
||||
|
||||
void loadFromFile( string const & n, vector< char > & data )
|
||||
{
|
||||
File::Class f( n, "rb" );
|
||||
|
||||
f.seekEnd();
|
||||
|
||||
data.resize( f.tell() );
|
||||
|
||||
f.rewind();
|
||||
|
||||
f.read( &data.front(), data.size() );
|
||||
}
|
||||
|
||||
void DslDictionary::getResource( string const & name,
|
||||
vector< char > & data )
|
||||
throw( Dictionary::exNoSuchResource, std::exception )
|
||||
|
@ -602,15 +626,18 @@ void DslDictionary::getResource( string const & name,
|
|||
|
||||
try
|
||||
{
|
||||
File::Class f( n, "rb" );
|
||||
try
|
||||
{
|
||||
loadFromFile( n, data );
|
||||
}
|
||||
catch( File::exCantOpen & )
|
||||
{
|
||||
n = getDictionaryFilenames()[ 0 ] + ".files" +
|
||||
FsEncoding::separator() +
|
||||
FsEncoding::encode( name );
|
||||
|
||||
f.seekEnd();
|
||||
|
||||
data.resize( f.tell() );
|
||||
|
||||
f.rewind();
|
||||
|
||||
f.read( &data.front(), data.size() );
|
||||
loadFromFile( n, data );
|
||||
}
|
||||
|
||||
if ( Filetype::isNameOfTiff( name ) )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue