aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/FileWatcherImpl.cpp
blob: bf69a4523c55df0728cc9d57028d74166fd93360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <efsw/FileWatcherImpl.hpp>
#include <efsw/String.hpp>
#include <efsw/System.hpp>

namespace efsw {

FileWatcherImpl::FileWatcherImpl( FileWatcher* parent ) :
	mFileWatcher( parent ), mInitOK( false ), mIsGeneric( false ) {
	System::maxFD();
}

FileWatcherImpl::~FileWatcherImpl() {}

bool FileWatcherImpl::initOK() {
	return static_cast<bool>( mInitOK );
}

bool FileWatcherImpl::linkAllowed( const std::string& curPath, const std::string& link ) {
	return ( mFileWatcher->followSymlinks() && mFileWatcher->allowOutOfScopeLinks() ) ||
		   -1 != String::strStartsWith( curPath, link );
}

int FileWatcherImpl::getOptionValue( const std::vector<WatcherOption>& options, Option option,
									 int defaultValue ) {
	for ( size_t i = 0; i < options.size(); i++ ) {
		if ( options[i].mOption == option ) {
			return options[i].mValue;
		}
	}

	return defaultValue;
}

} // namespace efsw