diff options
Diffstat (limited to 'src/3rdParty/efsw/FileWatcherImpl.hpp')
-rw-r--r--[-rwxr-xr-x] | src/3rdParty/efsw/FileWatcherImpl.hpp | 121 |
1 files changed, 64 insertions, 57 deletions
diff --git a/src/3rdParty/efsw/FileWatcherImpl.hpp b/src/3rdParty/efsw/FileWatcherImpl.hpp index ea1beb8..a6ec472 100755..100644 --- a/src/3rdParty/efsw/FileWatcherImpl.hpp +++ b/src/3rdParty/efsw/FileWatcherImpl.hpp | |||
@@ -1,57 +1,64 @@ | |||
1 | #ifndef EFSW_FILEWATCHERIMPL_HPP | 1 | #ifndef EFSW_FILEWATCHERIMPL_HPP |
2 | #define EFSW_FILEWATCHERIMPL_HPP | 2 | #define EFSW_FILEWATCHERIMPL_HPP |
3 | 3 | ||
4 | #include <efsw/Atomic.hpp> | 4 | #include <efsw/Atomic.hpp> |
5 | #include <efsw/Mutex.hpp> | 5 | #include <efsw/Mutex.hpp> |
6 | #include <efsw/Thread.hpp> | 6 | #include <efsw/Thread.hpp> |
7 | #include <efsw/Watcher.hpp> | 7 | #include <efsw/Watcher.hpp> |
8 | #include <efsw/base.hpp> | 8 | #include <efsw/base.hpp> |
9 | #include <efsw/efsw.hpp> | 9 | #include <efsw/efsw.hpp> |
10 | 10 | ||
11 | namespace efsw { | 11 | namespace efsw { |
12 | 12 | ||
13 | class FileWatcherImpl { | 13 | class FileWatcherImpl { |
14 | public: | 14 | public: |
15 | FileWatcherImpl( FileWatcher* parent ); | 15 | FileWatcherImpl( FileWatcher* parent ); |
16 | 16 | ||
17 | virtual ~FileWatcherImpl(); | 17 | virtual ~FileWatcherImpl(); |
18 | 18 | ||
19 | /// Add a directory watch | 19 | /// Add a directory watch |
20 | /// On error returns WatchID with Error type. | 20 | /// On error returns WatchID with Error type. |
21 | virtual WatchID addWatch( const std::string& directory, FileWatchListener* watcher, | 21 | virtual WatchID addWatch( const std::string& directory, FileWatchListener* watcher, |
22 | bool recursive ) = 0; | 22 | bool recursive, const std::vector<WatcherOption>& options = {} ) = 0; |
23 | 23 | ||
24 | /// Remove a directory watch. This is a brute force lazy search O(nlogn). | 24 | /// Remove a directory watch. This is a brute force lazy search O(nlogn). |
25 | virtual void removeWatch( const std::string& directory ) = 0; | 25 | virtual void removeWatch( const std::string& directory ) = 0; |
26 | 26 | ||
27 | /// Remove a directory watch. This is a map lookup O(logn). | 27 | /// Remove a directory watch. This is a map lookup O(logn). |
28 | virtual void removeWatch( WatchID watchid ) = 0; | 28 | virtual void removeWatch( WatchID watchid ) = 0; |
29 | 29 | ||
30 | /// Updates the watcher. Must be called often. | 30 | /// Updates the watcher. Must be called often. |
31 | virtual void watch() = 0; | 31 | virtual void watch() = 0; |
32 | 32 | ||
33 | /// Handles the action | 33 | /// Handles the action |
34 | virtual void handleAction( Watcher* watch, const std::string& filename, unsigned long action, | 34 | virtual void handleAction( Watcher* watch, const std::string& filename, unsigned long action, |
35 | std::string oldFilename = "" ) = 0; | 35 | std::string oldFilename = "" ) = 0; |
36 | 36 | ||
37 | /// @return Returns a list of the directories that are being watched | 37 | /// @return Returns a list of the directories that are being watched |
38 | virtual std::list<std::string> directories() = 0; | 38 | virtual std::vector<std::string> directories() = 0; |
39 | 39 | ||
40 | /// @return true if the backend init successfully | 40 | /// @return true if the backend init successfully |
41 | virtual bool initOK(); | 41 | virtual bool initOK(); |
42 | 42 | ||
43 | /// @return If the link is allowed according to the current path and the state of out scope | 43 | /// @return If the link is allowed according to the current path and the state of out scope |
44 | /// links | 44 | /// links |
45 | virtual bool linkAllowed( const std::string& curPath, const std::string& link ); | 45 | virtual bool linkAllowed( const std::string& curPath, const std::string& link ); |
46 | 46 | ||
47 | /// Search if a directory already exists in the watches | 47 | /// Search if a directory already exists in the watches |
48 | virtual bool pathInWatches( const std::string& path ) = 0; | 48 | virtual bool pathInWatches( const std::string& path ) = 0; |
49 | 49 | ||
50 | FileWatcher* mFileWatcher; | 50 | protected: |
51 | Atomic<bool> mInitOK; | 51 | friend class FileWatcher; |
52 | bool mIsGeneric; | 52 | friend class DirWatcherGeneric; |
53 | }; | 53 | |
54 | 54 | FileWatcher* mFileWatcher; | |
55 | } // namespace efsw | 55 | Atomic<bool> mInitOK; |
56 | 56 | bool mIsGeneric; | |
57 | #endif | 57 | |
58 | int getOptionValue( const std::vector<WatcherOption>& options, Option option, | ||
59 | int defaultValue ); | ||
60 | }; | ||
61 | |||
62 | } // namespace efsw | ||
63 | |||
64 | #endif | ||