aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/FileWatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdParty/efsw/FileWatcher.cpp')
-rw-r--r--[-rwxr-xr-x]src/3rdParty/efsw/FileWatcher.cpp239
1 files changed, 120 insertions, 119 deletions
diff --git a/src/3rdParty/efsw/FileWatcher.cpp b/src/3rdParty/efsw/FileWatcher.cpp
index 696a46f..f45b243 100755..100644
--- a/src/3rdParty/efsw/FileWatcher.cpp
+++ b/src/3rdParty/efsw/FileWatcher.cpp
@@ -1,119 +1,120 @@
1#include <efsw/FileSystem.hpp> 1#include <efsw/FileSystem.hpp>
2#include <efsw/FileWatcherGeneric.hpp> 2#include <efsw/FileWatcherGeneric.hpp>
3#include <efsw/FileWatcherImpl.hpp> 3#include <efsw/FileWatcherImpl.hpp>
4#include <efsw/efsw.hpp> 4#include <efsw/efsw.hpp>
5 5
6#if EFSW_PLATFORM == EFSW_PLATFORM_WIN32 6#if EFSW_PLATFORM == EFSW_PLATFORM_WIN32
7#include <efsw/FileWatcherWin32.hpp> 7#include <efsw/FileWatcherWin32.hpp>
8#define FILEWATCHER_IMPL FileWatcherWin32 8#define FILEWATCHER_IMPL FileWatcherWin32
9#define BACKEND_NAME "Win32" 9#define BACKEND_NAME "Win32"
10#elif EFSW_PLATFORM == EFSW_PLATFORM_INOTIFY 10#elif EFSW_PLATFORM == EFSW_PLATFORM_INOTIFY
11#include <efsw/FileWatcherInotify.hpp> 11#include <efsw/FileWatcherInotify.hpp>
12#define FILEWATCHER_IMPL FileWatcherInotify 12#define FILEWATCHER_IMPL FileWatcherInotify
13#define BACKEND_NAME "Inotify" 13#define BACKEND_NAME "Inotify"
14#elif EFSW_PLATFORM == EFSW_PLATFORM_KQUEUE 14#elif EFSW_PLATFORM == EFSW_PLATFORM_KQUEUE
15#include <efsw/FileWatcherKqueue.hpp> 15#include <efsw/FileWatcherKqueue.hpp>
16#define FILEWATCHER_IMPL FileWatcherKqueue 16#define FILEWATCHER_IMPL FileWatcherKqueue
17#define BACKEND_NAME "Kqueue" 17#define BACKEND_NAME "Kqueue"
18#elif EFSW_PLATFORM == EFSW_PLATFORM_FSEVENTS 18#elif EFSW_PLATFORM == EFSW_PLATFORM_FSEVENTS
19#include <efsw/FileWatcherFSEvents.hpp> 19#include <efsw/FileWatcherFSEvents.hpp>
20#define FILEWATCHER_IMPL FileWatcherFSEvents 20#define FILEWATCHER_IMPL FileWatcherFSEvents
21#define BACKEND_NAME "FSEvents" 21#define BACKEND_NAME "FSEvents"
22#else 22#else
23#define FILEWATCHER_IMPL FileWatcherGeneric 23#define FILEWATCHER_IMPL FileWatcherGeneric
24#define BACKEND_NAME "Generic" 24#define BACKEND_NAME "Generic"
25#endif 25#endif
26 26
27#include <efsw/Debug.hpp> 27#include <efsw/Debug.hpp>
28 28
29namespace efsw { 29namespace efsw {
30 30
31FileWatcher::FileWatcher() : mFollowSymlinks( false ), mOutOfScopeLinks( false ) { 31FileWatcher::FileWatcher() : mFollowSymlinks( false ), mOutOfScopeLinks( false ) {
32 efDEBUG( "Using backend: %s\n", BACKEND_NAME ); 32 efDEBUG( "Using backend: %s\n", BACKEND_NAME );
33 33
34 mImpl = new FILEWATCHER_IMPL( this ); 34 mImpl = new FILEWATCHER_IMPL( this );
35 35
36 if ( !mImpl->initOK() ) { 36 if ( !mImpl->initOK() ) {
37 efSAFE_DELETE( mImpl ); 37 efSAFE_DELETE( mImpl );
38 38
39 efDEBUG( "Falled back to backend: %s\n", BACKEND_NAME ); 39 efDEBUG( "Falled back to backend: %s\n", BACKEND_NAME );
40 40
41 mImpl = new FileWatcherGeneric( this ); 41 mImpl = new FileWatcherGeneric( this );
42 } 42 }
43} 43}
44 44
45FileWatcher::FileWatcher( bool useGenericFileWatcher ) : 45FileWatcher::FileWatcher( bool useGenericFileWatcher ) :
46 mFollowSymlinks( false ), mOutOfScopeLinks( false ) { 46 mFollowSymlinks( false ), mOutOfScopeLinks( false ) {
47 if ( useGenericFileWatcher ) { 47 if ( useGenericFileWatcher ) {
48 efDEBUG( "Using backend: Generic\n" ); 48 efDEBUG( "Using backend: Generic\n" );
49 49
50 mImpl = new FileWatcherGeneric( this ); 50 mImpl = new FileWatcherGeneric( this );
51 } else { 51 } else {
52 efDEBUG( "Using backend: %s\n", BACKEND_NAME ); 52 efDEBUG( "Using backend: %s\n", BACKEND_NAME );
53 53
54 mImpl = new FILEWATCHER_IMPL( this ); 54 mImpl = new FILEWATCHER_IMPL( this );
55 55
56 if ( !mImpl->initOK() ) { 56 if ( !mImpl->initOK() ) {
57 efSAFE_DELETE( mImpl ); 57 efSAFE_DELETE( mImpl );
58 58
59 efDEBUG( "Falled back to backend: %s\n", BACKEND_NAME ); 59 efDEBUG( "Falled back to backend: %s\n", BACKEND_NAME );
60 60
61 mImpl = new FileWatcherGeneric( this ); 61 mImpl = new FileWatcherGeneric( this );
62 } 62 }
63 } 63 }
64} 64}
65 65
66FileWatcher::~FileWatcher() { 66FileWatcher::~FileWatcher() {
67 efSAFE_DELETE( mImpl ); 67 efSAFE_DELETE( mImpl );
68} 68}
69 69
70WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher ) { 70WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher ) {
71 if ( mImpl->mIsGeneric || !FileSystem::isRemoteFS( directory ) ) { 71 return addWatch( directory, watcher, false, {} );
72 return mImpl->addWatch( directory, watcher, false ); 72}
73 } else { 73
74 return Errors::Log::createLastError( Errors::FileRemote, directory ); 74WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher,
75 } 75 bool recursive ) {
76} 76 return addWatch( directory, watcher, recursive, {} );
77 77}
78WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher, 78
79 bool recursive ) { 79WatchID FileWatcher::addWatch( const std::string& directory, FileWatchListener* watcher,
80 if ( mImpl->mIsGeneric || !FileSystem::isRemoteFS( directory ) ) { 80 bool recursive, const std::vector<WatcherOption>& options ) {
81 return mImpl->addWatch( directory, watcher, recursive ); 81 if ( mImpl->mIsGeneric || !FileSystem::isRemoteFS( directory ) ) {
82 } else { 82 return mImpl->addWatch( directory, watcher, recursive, options );
83 return Errors::Log::createLastError( Errors::FileRemote, directory ); 83 } else {
84 } 84 return Errors::Log::createLastError( Errors::FileRemote, directory );
85} 85 }
86 86}
87void FileWatcher::removeWatch( const std::string& directory ) { 87
88 mImpl->removeWatch( directory ); 88void FileWatcher::removeWatch( const std::string& directory ) {
89} 89 mImpl->removeWatch( directory );
90 90}
91void FileWatcher::removeWatch( WatchID watchid ) { 91
92 mImpl->removeWatch( watchid ); 92void FileWatcher::removeWatch( WatchID watchid ) {
93} 93 mImpl->removeWatch( watchid );
94 94}
95void FileWatcher::watch() { 95
96 mImpl->watch(); 96void FileWatcher::watch() {
97} 97 mImpl->watch();
98 98}
99std::list<std::string> FileWatcher::directories() { 99
100 return mImpl->directories(); 100std::vector<std::string> FileWatcher::directories() {
101} 101 return mImpl->directories();
102 102}
103void FileWatcher::followSymlinks( bool follow ) { 103
104 mFollowSymlinks = follow; 104void FileWatcher::followSymlinks( bool follow ) {
105} 105 mFollowSymlinks = follow;
106 106}
107const bool& FileWatcher::followSymlinks() const { 107
108 return mFollowSymlinks; 108const bool& FileWatcher::followSymlinks() const {
109} 109 return mFollowSymlinks;
110 110}
111void FileWatcher::allowOutOfScopeLinks( bool allow ) { 111
112 mOutOfScopeLinks = allow; 112void FileWatcher::allowOutOfScopeLinks( bool allow ) {
113} 113 mOutOfScopeLinks = allow;
114 114}
115const bool& FileWatcher::allowOutOfScopeLinks() const { 115
116 return mOutOfScopeLinks; 116const bool& FileWatcher::allowOutOfScopeLinks() const {
117} 117 return mOutOfScopeLinks;
118 118}
119} // namespace efsw 119
120} // namespace efsw