From: Erwan Tulou Date: Wed, 10 Mar 2010 15:20:25 +0000 (+0100) Subject: skins2: fix skins broken because of wrong path separator X-Git-Tag: 1.1.0-pre1~424 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a18b31a4c0f496f800e598b82238f55476dca02d;p=vlc 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. --- diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp index 3254c72993..74c0a62e61 100644 --- a/modules/gui/skins2/parser/builder.cpp +++ b/modules/gui/skins2/parser/builder.cpp @@ -1155,7 +1155,26 @@ GenericFont *Builder::getFont( const string &fontId ) string Builder::getFilePath( const string &rFileName ) const { 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 ); }