void X11Factory::rmDir( const string &rPath )
{
+ struct
+ {
+ struct dirent ent;
+ char buf[NAME_MAX + 1];
+ } buf;
struct dirent *file;
DIR *dir;
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;
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 );
}