]> git.sesse.net Git - vlc/commitdiff
skins: use readdir_r() instead of readdir()
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 17 Apr 2010 14:49:47 +0000 (17:49 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 17 Apr 2010 14:56:10 +0000 (17:56 +0300)
modules/gui/skins2/x11/x11_factory.cpp

index f203de836bfed05e752bce19848ab83bdb020760..fa54582c1a609b7e3a58992dc605a847925249fe 100644 (file)
@@ -201,6 +201,11 @@ void X11Factory::getMousePos( int &rXPos, int &rYPos ) const
 
 void X11Factory::rmDir( const string &rPath )
 {
+    struct
+    {
+        struct dirent ent;
+        char buf[NAME_MAX + 1];
+    } buf;
     struct dirent *file;
     DIR *dir;
 
@@ -208,7 +213,7 @@ void X11Factory::rmDir( const string &rPath )
     if( !dir ) return;
 
     // Parse the directory and remove everything it contains
-    while( (file = readdir( dir )) )
+    while( readdir_r( dir, &buf.ent, &file ) == 0 && file != NULL )
     {
         struct stat statbuf;
         string filename = file->d_name;
@@ -221,7 +226,7 @@ void X11Factory::rmDir( const string &rPath )
 
         filename = rPath + "/" + filename;
 
-        if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
+        if( !stat( filename.c_str(), &statbuf ) && S_ISDIR(statbuf.st_mode) )
         {
             rmDir( filename );
         }