[vlc-commits] skins2: fix .wsz problem

Erwan Tulou git at videolan.org
Tue Mar 1 21:19:47 CET 2011


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Tue Mar  1 16:45:15 2011 +0100| [39c660424ba5e147044ef377d447462ac9ea946c] | committer: Erwan Tulou

skins2: fix .wsz problem

filenames must always be forced to lower case in the case of .wsz files
(since the winamp2.xml expects them in this form)

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

 modules/gui/skins2/src/ini_file.cpp     |    4 +---
 modules/gui/skins2/src/theme_loader.cpp |   18 ++++++++----------
 modules/gui/skins2/src/theme_loader.hpp |    2 +-
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/modules/gui/skins2/src/ini_file.cpp b/modules/gui/skins2/src/ini_file.cpp
index 7fe8282..58478d2 100644
--- a/modules/gui/skins2/src/ini_file.cpp
+++ b/modules/gui/skins2/src/ini_file.cpp
@@ -68,13 +68,11 @@ void IniFile::parseFile()
 
                 string name = m_name + "." + section + "." + var;
 
-#ifdef WIN32
                 // Convert to lower case because of some buggy winamp2 skins
-                for( size_t i=0; i< name.size(); i++)
+                for( size_t i = 0; i < name.size(); i++ )
                 {
                     name[i] = tolower( name[i] );
                 }
-#endif
 
                 // Register the value in the var manager
                 pVarManager->registerConst( name, val );
diff --git a/modules/gui/skins2/src/theme_loader.cpp b/modules/gui/skins2/src/theme_loader.cpp
index 7696026..b976ff7 100644
--- a/modules/gui/skins2/src/theme_loader.cpp
+++ b/modules/gui/skins2/src/theme_loader.cpp
@@ -136,6 +136,8 @@ bool ThemeLoader::extractTarGz( const string &tarFile, const string &rootDir )
 
 bool ThemeLoader::extractZip( const string &zipFile, const string &rootDir )
 {
+    bool b_isWsz = strstr( zipFile.c_str(), ".wsz" );
+
     // Try to open the ZIP file
     unzFile file = unzOpen( zipFile.c_str() );
     unz_global_info info;
@@ -147,7 +149,7 @@ bool ThemeLoader::extractZip( const string &zipFile, const string &rootDir )
     // Extract all the files in the archive
     for( unsigned long i = 0; i < info.number_entry; i++ )
     {
-        if( !extractFileInZip( file, rootDir ) )
+        if( !extractFileInZip( file, rootDir, b_isWsz ) )
         {
             msg_Warn( getIntf(), "error while unzipping %s",
                       zipFile.c_str() );
@@ -172,7 +174,8 @@ bool ThemeLoader::extractZip( const string &zipFile, const string &rootDir )
 }
 
 
-bool ThemeLoader::extractFileInZip( unzFile file, const string &rootDir )
+bool ThemeLoader::extractFileInZip( unzFile file, const string &rootDir,
+                                    bool isWsz )
 {
     // Read info for the current file
     char filenameInZip[256];
@@ -184,16 +187,11 @@ bool ThemeLoader::extractFileInZip( unzFile file, const string &rootDir )
         return false;
     }
 
-#ifdef WIN32
-
     // Convert the file name to lower case, because some winamp skins
     // use the wrong case...
-    for( size_t i=0; i< strlen( filenameInZip ); i++)
-    {
-        filenameInZip[i] = tolower( filenameInZip[i] );
-    }
-
-#endif
+    if( isWsz )
+        for( size_t i = 0; i < strlen( filenameInZip ); i++ )
+            filenameInZip[i] = tolower( filenameInZip[i] );
 
     // Allocate the buffer
     void *pBuffer = malloc( ZIP_BUFFER_SIZE );
diff --git a/modules/gui/skins2/src/theme_loader.hpp b/modules/gui/skins2/src/theme_loader.hpp
index 52457d1..99d43ac 100644
--- a/modules/gui/skins2/src/theme_loader.hpp
+++ b/modules/gui/skins2/src/theme_loader.hpp
@@ -64,7 +64,7 @@ private:
     /**
      * Expects a string from the current locale.
      */
-    bool extractFileInZip( unzFile file, const string &rootDir );
+    bool extractFileInZip( unzFile file, const string &rootDir, bool isWsz );
 
     /// Clean up the temporary files created by the extraction
     /**



More information about the vlc-commits mailing list