aboutsummaryrefslogtreecommitdiff
path: root/dep/efsw/src/efsw/FileWatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dep/efsw/src/efsw/FileWatcher.cpp')
-rw-r--r--dep/efsw/src/efsw/FileWatcher.cpp119
1 files changed, 47 insertions, 72 deletions
diff --git a/dep/efsw/src/efsw/FileWatcher.cpp b/dep/efsw/src/efsw/FileWatcher.cpp
index e33d5ec46fb..ab3ec4bd679 100644
--- a/dep/efsw/src/efsw/FileWatcher.cpp
+++ b/dep/efsw/src/efsw/FileWatcher.cpp
@@ -1,43 +1,39 @@
-#include <efsw/efsw.hpp>
-#include <efsw/FileWatcherImpl.hpp>
-#include <efsw/FileWatcherGeneric.hpp>
#include <efsw/FileSystem.hpp>
+#include <efsw/FileWatcherGeneric.hpp>
+#include <efsw/FileWatcherImpl.hpp>
+#include <efsw/efsw.hpp>
#if EFSW_PLATFORM == EFSW_PLATFORM_WIN32
-# include <efsw/FileWatcherWin32.hpp>
-# define FILEWATCHER_IMPL FileWatcherWin32
-# define BACKEND_NAME "Win32"
+#include <efsw/FileWatcherWin32.hpp>
+#define FILEWATCHER_IMPL FileWatcherWin32
+#define BACKEND_NAME "Win32"
#elif EFSW_PLATFORM == EFSW_PLATFORM_INOTIFY
-# include <efsw/FileWatcherInotify.hpp>
-# define FILEWATCHER_IMPL FileWatcherInotify
-# define BACKEND_NAME "Inotify"
+#include <efsw/FileWatcherInotify.hpp>
+#define FILEWATCHER_IMPL FileWatcherInotify
+#define BACKEND_NAME "Inotify"
#elif EFSW_PLATFORM == EFSW_PLATFORM_KQUEUE
-# include <efsw/FileWatcherKqueue.hpp>
-# define FILEWATCHER_IMPL FileWatcherKqueue
-# define BACKEND_NAME "Kqueue"
+#include <efsw/FileWatcherKqueue.hpp>
+#define FILEWATCHER_IMPL FileWatcherKqueue
+#define BACKEND_NAME "Kqueue"
#elif EFSW_PLATFORM == EFSW_PLATFORM_FSEVENTS
-# include <efsw/FileWatcherFSEvents.hpp>
-# define FILEWATCHER_IMPL FileWatcherFSEvents
-# define BACKEND_NAME "FSEvents"
+#include <efsw/FileWatcherFSEvents.hpp>
+#define FILEWATCHER_IMPL FileWatcherFSEvents
+#define BACKEND_NAME "FSEvents"
#else
-# define FILEWATCHER_IMPL FileWatcherGeneric
-# define BACKEND_NAME "Generic"
+#define FILEWATCHER_IMPL FileWatcherGeneric
+#define BACKEND_NAME "Generic"
#endif
#include <efsw/Debug.hpp>
namespace efsw {
-FileWatcher::FileWatcher() :
- mFollowSymlinks(false),
- mOutOfScopeLinks(false)
-{
+FileWatcher::FileWatcher() : mFollowSymlinks( false ), mOutOfScopeLinks( false ) {
efDEBUG( "Using backend: %s\n", BACKEND_NAME );
mImpl = new FILEWATCHER_IMPL( this );
- if ( !mImpl->initOK() )
- {
+ if ( !mImpl->initOK() ) {
efSAFE_DELETE( mImpl );
efDEBUG( "Falled back to backend: %s\n", BACKEND_NAME );
@@ -47,23 +43,17 @@ FileWatcher::FileWatcher() :
}
FileWatcher::FileWatcher( bool useGenericFileWatcher ) :
- mFollowSymlinks(false),
- mOutOfScopeLinks(false)
-{
- if ( useGenericFileWatcher )
- {
+ mFollowSymlinks( false ), mOutOfScopeLinks( false ) {
+ if ( useGenericFileWatcher ) {
efDEBUG( "Using backend: Generic\n" );
mImpl = new FileWatcherGeneric( this );
- }
- else
- {
+ } else {
efDEBUG( "Using backend: %s\n", BACKEND_NAME );
mImpl = new FILEWATCHER_IMPL( this );
- if ( !mImpl->initOK() )
- {
+ if ( !mImpl->initOK() ) {
efSAFE_DELETE( mImpl );
efDEBUG( "Falled back to backend: %s\n", BACKEND_NAME );
@@ -73,73 +63,58 @@ FileWatcher::FileWatcher( bool useGenericFileWatcher ) :
}
}
-FileWatcher::~FileWatcher()
-{
+FileWatcher::~FileWatcher() {
efSAFE_DELETE( mImpl );
}
-WatchID FileWatcher::addWatch(const std::string& directory, FileWatchListener* watcher)
-{
- if ( mImpl->mIsGeneric || !FileSystem::isRemoteFS( directory ) )
- {
- return mImpl->addWatch(directory, watcher, false);
- }
- else
- {
- return Errors::Log::createLastError( Errors::FileRemote, directory );
- }
+WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher ) {
+ return addWatch( directory, watcher, false, {} );
}
-WatchID FileWatcher::addWatch(const std::string& directory, FileWatchListener* watcher, bool recursive)
-{
- if ( mImpl->mIsGeneric || !FileSystem::isRemoteFS( directory ) )
- {
- return mImpl->addWatch(directory, watcher, recursive);
- }
- else
- {
+WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher,
+ bool recursive ) {
+ return addWatch( directory, watcher, recursive, {} );
+}
+
+WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher,
+ bool recursive, const std::vector<WatcherOption>& options ) {
+ if ( mImpl->mIsGeneric || !FileSystem::isRemoteFS( directory ) ) {
+ return mImpl->addWatch( directory, watcher, recursive, options );
+ } else {
return Errors::Log::createLastError( Errors::FileRemote, directory );
}
}
-void FileWatcher::removeWatch(const std::string& directory)
-{
- mImpl->removeWatch(directory);
+void FileWatcher::removeWatch( const std::string& directory ) {
+ mImpl->removeWatch( directory );
}
-void FileWatcher::removeWatch(WatchID watchid)
-{
- mImpl->removeWatch(watchid);
+void FileWatcher::removeWatch( WatchID watchid ) {
+ mImpl->removeWatch( watchid );
}
-void FileWatcher::watch()
-{
+void FileWatcher::watch() {
mImpl->watch();
}
-std::list<std::string> FileWatcher::directories()
-{
+std::vector<std::string> FileWatcher::directories() {
return mImpl->directories();
}
-void FileWatcher::followSymlinks( bool follow )
-{
+void FileWatcher::followSymlinks( bool follow ) {
mFollowSymlinks = follow;
}
-const bool& FileWatcher::followSymlinks() const
-{
+const bool& FileWatcher::followSymlinks() const {
return mFollowSymlinks;
}
-void FileWatcher::allowOutOfScopeLinks( bool allow )
-{
+void FileWatcher::allowOutOfScopeLinks( bool allow ) {
mOutOfScopeLinks = allow;
}
-const bool& FileWatcher::allowOutOfScopeLinks() const
-{
+const bool& FileWatcher::allowOutOfScopeLinks() const {
return mOutOfScopeLinks;
}
-}
+} // namespace efsw