From 4dfdeb4a1a2929b6db5d740f9184b4f7b0306f6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <rem@videolan.org>
Date: Sat, 25 Nov 2006 14:38:54 +0000
Subject: [PATCH] Use utf8 directory wrappers

---
 modules/gui/skins2/src/theme_repository.cpp | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/gui/skins2/src/theme_repository.cpp b/modules/gui/skins2/src/theme_repository.cpp
index 7cd5fbc9de99..3db8a424bd7e 100644
--- a/modules/gui/skins2/src/theme_repository.cpp
+++ b/modules/gui/skins2/src/theme_repository.cpp
@@ -95,16 +95,18 @@ ThemeRepository::~ThemeRepository()
 }
 
 
-void ThemeRepository::parseDirectory( const string &rDir )
+void ThemeRepository::parseDirectory( const string &rDir_locale )
 {
     DIR *pDir;
-    struct dirent *pDirContent;
+    char *pszDirContent;
     vlc_value_t val, text;
     // Path separator
     const string &sep = OSFactory::instance( getIntf() )->getDirSeparator();
 
     // Open the dir
-    pDir = opendir( rDir.c_str() );
+    // FIXME: parseDirectory should be invoked with UTF-8 input instead!!
+    string rDir = sFromLocale( rDir_locale );
+    pDir = utf8_opendir( rDir.c_str() );
 
     if( pDir == NULL )
     {
@@ -113,13 +115,10 @@ void ThemeRepository::parseDirectory( const string &rDir )
         return;
     }
 
-    // Get the first directory entry
-    pDirContent = (dirent*)readdir( pDir );
-
     // While we still have entries in the directory
-    while( pDirContent != NULL )
+    while( ( pszDirContent = utf8_readdir( pDir ) ) != NULL )
     {
-        string name = pDirContent->d_name;
+        string name = pszDirContent;
         string extension;
         if( name.size() > 4 )
         {
@@ -142,7 +141,7 @@ void ThemeRepository::parseDirectory( const string &rDir )
             delete[] text.psz_string;
         }
 
-        pDirContent = (dirent*)readdir( pDir );
+        free( pszDirContent );
     }
 
     closedir( pDir );
-- 
GitLab