]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/theme_loader.cpp
Remove useless <dirent.h> check
[vlc] / modules / gui / skins2 / src / theme_loader.cpp
index 3f0d106271872170d709d81c1944fc88fe2e5d9a..7a67113c8831ecae8093979ad8f229f9a50af5fe 100644 (file)
@@ -30,8 +30,6 @@
 #include "../src/vlcproc.hpp"
 #include "../src/window_manager.hpp"
 
-#include <cctype>
-
 #ifdef HAVE_FCNTL_H
 #   include <fcntl.h>
 #endif
 #   include <direct.h>
 #endif
 
-#ifdef HAVE_DIRENT_H
-#   include <dirent.h>
-#endif
-
-
 #if defined( HAVE_ZLIB_H )
 #   include <zlib.h>
 #   include <errno.h>
@@ -79,7 +72,7 @@ bool ThemeLoader::load( const string &fileName )
 
     //Before all, let's see if the file is present
     struct stat p_stat;
-    if( utf8_stat( path.c_str(), &p_stat ) )
+    if( vlc_stat( fileName.c_str(), &p_stat ) )
         return false;
 
     // First, we try to un-targz the file, and if it fails we hope it's a XML
@@ -95,26 +88,13 @@ bool ThemeLoader::load( const string &fileName )
 
     Theme *pNewTheme = getIntf()->p_sys->p_theme;
     if( !pNewTheme )
-    {
         return false;
-    }
 
-    // Check if the skin to load is in the config file, to load its config
-    char *skin_last = config_GetPsz( getIntf(), "skins2-last" );
-    if( skin_last != NULL && fileName == (string)skin_last )
-    {
-        // Restore the theme configuration
-        getIntf()->p_sys->p_theme->loadConfig();
-        // Used to anchor the windows at the beginning
-        pNewTheme->getWindowManager().stopMove();
-    }
-    else
-    {
-        config_PutPsz( getIntf(), "skins2-last", fileName.c_str() );
-        // Show the windows
-        pNewTheme->getWindowManager().showAll( true );
-    }
-    free( skin_last );
+    // Restore the theme configuration
+    getIntf()->p_sys->p_theme->loadConfig();
+
+    // Retain new loaded skins in config
+    config_PutPsz( getIntf(), "skins2-last", fileName.c_str() );
 
     return true;
 }
@@ -204,6 +184,8 @@ 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++)
@@ -211,6 +193,8 @@ bool ThemeLoader::extractFileInZip( unzFile file, const string &rootDir )
         filenameInZip[i] = tolower( filenameInZip[i] );
     }
 
+#endif
+
     // Allocate the buffer
     void *pBuffer = malloc( ZIP_BUFFER_SIZE );
     if( !pBuffer )
@@ -413,7 +397,7 @@ bool ThemeLoader::findFile( const string &rootDir, const string &rFileName,
     char *pszDirContent;
 
     // Open the dir
-    pCurrDir = utf8_opendir( rootDir.c_str() );
+    pCurrDir = vlc_opendir( rootDir.c_str() );
 
     if( pCurrDir == NULL )
     {
@@ -423,7 +407,7 @@ bool ThemeLoader::findFile( const string &rootDir, const string &rFileName,
     }
 
     // While we still have entries in the directory
-    while( ( pszDirContent = utf8_readdir( pCurrDir ) ) != NULL )
+    while( ( pszDirContent = vlc_readdir( pCurrDir ) ) != NULL )
     {
         string newURI = rootDir + sep + pszDirContent;
 
@@ -434,7 +418,7 @@ bool ThemeLoader::findFile( const string &rootDir, const string &rFileName,
 #if defined( S_ISDIR )
             struct stat stat_data;
 
-            if( ( utf8_stat( newURI.c_str(), &stat_data ) == 0 )
+            if( ( vlc_stat( newURI.c_str(), &stat_data ) == 0 )
              && S_ISDIR(stat_data.st_mode) )
 #elif defined( DT_DIR )
             if( pDirContent->d_type & DT_DIR )
@@ -575,34 +559,33 @@ int tar_extract_all( TAR *t, char *prefix )
 
             switch( buffer.header.typeflag )
             {
-                case DIRTYPE:
-                    makedir( fname );
-                    break;
-                case REGTYPE:
-                case AREGTYPE:
-                    remaining = getoct( buffer.header.size, 12 );
-                    if( remaining )
+            case DIRTYPE:
+                makedir( fname );
+                break;
+            case REGTYPE:
+            case AREGTYPE:
+                remaining = getoct( buffer.header.size, 12 );
+                if( !remaining ) outfile = NULL; else
+                {
+                    outfile = fopen( fname, "wb" );
+                    if( outfile == NULL )
                     {
-                        outfile = fopen( fname, "wb" );
-                        if( outfile == NULL )
+                        /* try creating directory */
+                        char *p = strrchr( fname, '/' );
+                        if( p != NULL )
                         {
-                            /* try creating directory */
-                            char *p = strrchr( fname, '/' );
-                            if( p != NULL )
+                            *p = '\0';
+                            makedir( fname );
+                            *p = '/';
+                            outfile = fopen( fname, "wb" );
+                            if( !outfile )
                             {
-                                *p = '\0';
-                                makedir( fname );
-                                *p = '/';
-                                outfile = fopen( fname, "wb" );
-                                if( !outfile )
-                                {
-                                    fprintf( stderr, "tar couldn't create %s\n",
-                                             fname );
-                                }
+                                fprintf( stderr, "tar couldn't create %s\n",
+                                         fname );
                             }
                         }
                     }
-                    else outfile = NULL;
+                }
 
                 /*
                  * could have no contents
@@ -737,16 +720,16 @@ int gzopen_frontend( const char *pathname, int oflags, int mode )
 
     switch( oflags )
     {
-        case O_WRONLY:
-            gzflags = "wb";
-            break;
-        case O_RDONLY:
-            gzflags = "rb";
-            break;
-        case O_RDWR:
-        default:
-            errno = EINVAL;
-            return -1;
+    case O_WRONLY:
+        gzflags = "wb";
+        break;
+    case O_RDONLY:
+        gzflags = "rb";
+        break;
+    case O_RDWR:
+    default:
+        errno = EINVAL;
+        return -1;
     }
 
     gzf = gzopen( pathname, gzflags );