diff options
Diffstat (limited to 'src/3rdParty/efsw/FileWatcherCWrapper.cpp')
-rw-r--r--[-rwxr-xr-x] | src/3rdParty/efsw/FileWatcherCWrapper.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/3rdParty/efsw/FileWatcherCWrapper.cpp b/src/3rdParty/efsw/FileWatcherCWrapper.cpp index 5c49a66..8712d6e 100755..100644 --- a/src/3rdParty/efsw/FileWatcherCWrapper.cpp +++ b/src/3rdParty/efsw/FileWatcherCWrapper.cpp | |||
@@ -28,12 +28,12 @@ class Watcher_CAPI : public efsw::FileWatchListener { | |||
28 | */ | 28 | */ |
29 | static std::vector<Watcher_CAPI*> g_callbacks; | 29 | static std::vector<Watcher_CAPI*> g_callbacks; |
30 | 30 | ||
31 | Watcher_CAPI* find_callback( efsw_watcher watcher, efsw_pfn_fileaction_callback fn ) { | 31 | Watcher_CAPI* find_callback( efsw_watcher watcher, efsw_pfn_fileaction_callback fn, void* param ) { |
32 | for ( std::vector<Watcher_CAPI*>::iterator i = g_callbacks.begin(); i != g_callbacks.end(); | 32 | for ( std::vector<Watcher_CAPI*>::iterator i = g_callbacks.begin(); i != g_callbacks.end(); |
33 | ++i ) { | 33 | ++i ) { |
34 | Watcher_CAPI* callback = *i; | 34 | Watcher_CAPI* callback = *i; |
35 | 35 | ||
36 | if ( callback->mFn == fn && callback->mWatcher == watcher ) | 36 | if ( callback->mFn == fn && callback->mWatcher == watcher && callback->mParam == param ) |
37 | return *i; | 37 | return *i; |
38 | } | 38 | } |
39 | 39 | ||
@@ -71,17 +71,35 @@ const char* efsw_getlasterror() { | |||
71 | return log_str.c_str(); | 71 | return log_str.c_str(); |
72 | } | 72 | } |
73 | 73 | ||
74 | EFSW_API void efsw_clearlasterror() { | ||
75 | efsw::Errors::Log::clearLastError(); | ||
76 | } | ||
77 | |||
74 | efsw_watchid efsw_addwatch( efsw_watcher watcher, const char* directory, | 78 | efsw_watchid efsw_addwatch( efsw_watcher watcher, const char* directory, |
75 | efsw_pfn_fileaction_callback callback_fn, int recursive, void* param ) { | 79 | efsw_pfn_fileaction_callback callback_fn, int recursive, void* param ) { |
76 | Watcher_CAPI* callback = find_callback( watcher, callback_fn ); | 80 | return efsw_addwatch_withoptions( watcher, directory, callback_fn, recursive, 0, 0, param ); |
81 | } | ||
82 | |||
83 | efsw_watchid efsw_addwatch_withoptions(efsw_watcher watcher, const char* directory, | ||
84 | efsw_pfn_fileaction_callback callback_fn, int recursive, | ||
85 | efsw_watcher_option *options, int options_number, | ||
86 | void* param) { | ||
87 | Watcher_CAPI* callback = find_callback( watcher, callback_fn, param ); | ||
77 | 88 | ||
78 | if ( callback == NULL ) { | 89 | if ( callback == NULL ) { |
79 | callback = new Watcher_CAPI( watcher, callback_fn, param ); | 90 | callback = new Watcher_CAPI( watcher, callback_fn, param ); |
80 | g_callbacks.push_back( callback ); | 91 | g_callbacks.push_back( callback ); |
81 | } | 92 | } |
82 | 93 | ||
94 | std::vector<efsw::WatcherOption> watcher_options{}; | ||
95 | for ( int i = 0; i < options_number; i++ ) { | ||
96 | efsw_watcher_option* option = &options[i]; | ||
97 | watcher_options.emplace_back( efsw::WatcherOption{ | ||
98 | static_cast<efsw::Option>(option->option), option->value } ); | ||
99 | } | ||
100 | |||
83 | return ( (efsw::FileWatcher*)watcher ) | 101 | return ( (efsw::FileWatcher*)watcher ) |
84 | ->addWatch( std::string( directory ), callback, TOBOOL( recursive ) ); | 102 | ->addWatch( std::string( directory ), callback, TOBOOL( recursive ), watcher_options ); |
85 | } | 103 | } |
86 | 104 | ||
87 | void efsw_removewatch( efsw_watcher watcher, const char* directory ) { | 105 | void efsw_removewatch( efsw_watcher watcher, const char* directory ) { |