]> git.sesse.net Git - vlc/commitdiff
skins2: fix skins broken because of wrong path separator
authorErwan Tulou <erwan10@videolan.org>
Wed, 10 Mar 2010 15:20:25 +0000 (16:20 +0100)
committerErwan Tulou <erwan10@videolan.org>
Wed, 10 Mar 2010 16:08:27 +0000 (17:08 +0100)
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.

modules/gui/skins2/parser/builder.cpp

index 3254c7299336afc37453ed489c93e25b8d40af1b..74c0a62e611604b7724ec67e8337923171e00b82 100644 (file)
@@ -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 );
 }