FileWatcher::FileWatcher( bool useGenericFileWatcher ) : mFollowSymlinks(false), mOutOfScopeLinks(false) { if ( useGenericFileWatcher ) { efDEBUG( "Using backend: Generic\n" ); mImpl = new FileWatcherGeneric( this ); } else { efDEBUG( "Using backend: %s\n", BACKEND_NAME ); mImpl = new FILEWATCHER_IMPL( this ); if ( !mImpl->initOK() ) { efSAFE_DELETE( mImpl ); efDEBUG( "Falled back to backend: %s\n", BACKEND_NAME ); mImpl = new FileWatcherGeneric( this ); } } }
FileWatcherGeneric::~FileWatcherGeneric() { mInitOK = false; mThread->wait(); efSAFE_DELETE( mThread ); /// Delete the watches WatchList::iterator it = mWatches.begin(); for ( ; it != mWatches.end(); it++ ) { efSAFE_DELETE( (*it) ); } }
void Thread::terminate() { if ( mThreadImpl ) { mThreadImpl->terminate(); efSAFE_DELETE( mThreadImpl ); } }
void Thread::wait() { if ( mThreadImpl ) { mThreadImpl->wait(); efSAFE_DELETE( mThreadImpl ); } }
FileWatcherWin32::~FileWatcherWin32() { WatchVector::iterator iter = mWatches.begin(); mWatchesLock.lock(); for(; iter != mWatches.end(); ++iter) { DestroyWatch((*iter)); } mHandles.clear(); mWatches.clear(); mInitOK = false; mWatchesLock.unlock(); efSAFE_DELETE( mThread ); }
void FileWatcherGeneric::removeWatch( const std::string& directory ) { WatchList::iterator it = mWatches.begin(); for ( ; it != mWatches.end(); it++ ) { if ( (*it)->Directory == directory ) { WatcherGeneric * watch = (*it); mWatchesLock.lock(); mWatches.erase( it ); efSAFE_DELETE( watch ) ; mWatchesLock.unlock(); return; } } }
void FileWatcherGeneric::removeWatch(WatchID watchid) { WatchList::iterator it = mWatches.begin(); for ( ; it != mWatches.end(); it++ ) { if ( (*it)->ID == watchid ) { WatcherGeneric * watch = (*it); mWatchesLock.lock(); mWatches.erase( it ); efSAFE_DELETE( watch ) ; mWatchesLock.unlock(); return; } } }
FileWatcher::~FileWatcher() { efSAFE_DELETE( mImpl ); }
WatcherGeneric::~WatcherGeneric() { efSAFE_DELETE( DirWatch ); }
Thread::~Thread() { wait(); efSAFE_DELETE( mEntryPoint ); }