Commit a18b31a4 authored by Erwan Tulou's avatar Erwan Tulou

skins2: fix skins broken because of wrong path separator

In skins, slash is the preferred path separator for both Linux and Win32
yet, rather fix those separators and issue a warning than fail to open skins.
parent 7c1dc4d1
...@@ -1155,7 +1155,26 @@ GenericFont *Builder::getFont( const string &fontId ) ...@@ -1155,7 +1155,26 @@ GenericFont *Builder::getFont( const string &fontId )
string Builder::getFilePath( const string &rFileName ) const string Builder::getFilePath( const string &rFileName ) const
{ {
OSFactory *pFactory = OSFactory::instance( getIntf() ); OSFactory *pFactory = OSFactory::instance( getIntf() );
return m_path + pFactory->getDirSeparator() + sFromLocale( rFileName ); const string &sep = pFactory->getDirSeparator();
string file = rFileName;
if( file.find( "\\" ) != string::npos )
{
// For skins to be valid on both Linux and Win32,
// slash should be used as path separator for both OSs.
msg_Warn( getIntf(), "use of '/' is preferred to '\\' for paths" );
int pos;
while( ( pos = file.find( "\\" ) ) != string::npos )
file[pos] = '/';
}
#ifdef WIN32
int pos;
while( ( pos = file.find( "/" ) ) != string::npos )
file.replace( pos, 1, sep );
#endif
return m_path + sep + sFromLocale( file );
} }
......
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