#include <dirent.h>
#include <sys/stat.h>
#include <X11/Xlib.h>
+#include <limits.h>
#include "x11_factory.hpp"
#include "x11_display.hpp"
#include "../src/generic_window.hpp"
+#include <vlc_common.h>
+#include <vlc_xlib.h>
+
X11Factory::X11Factory( intf_thread_t *pIntf ): OSFactory( pIntf ),
m_pDisplay( NULL ), m_pTimerLoop( NULL ), m_dirSep( "/" )
{
bool X11Factory::init()
{
// make sure xlib is safe-thread
- if( !XInitThreads() )
+ if( !vlc_xlib_init( VLC_OBJECT( getIntf() ) ) )
+ {
msg_Err( getIntf(), "initializing xlib for multi-threading failed" );
+ return false;
+ }
// Create the X11 display
m_pDisplay = new X11Display( getIntf() );
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( readdir_r( dir, &buf.ent, &file ) == 0 && file != NULL )
+ while( (file = readdir( dir )) )
{
struct stat statbuf;
string filename = file->d_name;
filename = rPath + "/" + filename;
- if( !stat( filename.c_str(), &statbuf ) && S_ISDIR(statbuf.st_mode) )
+ if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
{
rmDir( filename );
}