[vlc-commits] commit: skins2: fix skins broken because of wrong path separator ( Erwan Tulou )

git at videolan.org git at videolan.org
Wed Mar 10 17:10:19 CET 2010


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Wed Mar 10 16:20:25 2010 +0100| [a18b31a4c0f496f800e598b82238f55476dca02d] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a18b31a4c0f496f800e598b82238f55476dca02d
---

 modules/gui/skins2/parser/builder.cpp |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp
index 3254c72..74c0a62 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 );
 }
 
 



More information about the vlc-commits mailing list