From 9750786a5c03b5ce3ea22b240d1b3cd34990856b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 9 Apr 2025 17:40:13 +0800 Subject: Updated efsw. Fixed issue #204. --- src/3rdParty/efsw/FileWatcherImpl.hpp | 121 ++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 57 deletions(-) mode change 100755 => 100644 src/3rdParty/efsw/FileWatcherImpl.hpp (limited to 'src/3rdParty/efsw/FileWatcherImpl.hpp') diff --git a/src/3rdParty/efsw/FileWatcherImpl.hpp b/src/3rdParty/efsw/FileWatcherImpl.hpp old mode 100755 new mode 100644 index ea1beb8..a6ec472 --- a/src/3rdParty/efsw/FileWatcherImpl.hpp +++ b/src/3rdParty/efsw/FileWatcherImpl.hpp @@ -1,57 +1,64 @@ -#ifndef EFSW_FILEWATCHERIMPL_HPP -#define EFSW_FILEWATCHERIMPL_HPP - -#include -#include -#include -#include -#include -#include - -namespace efsw { - -class FileWatcherImpl { - public: - FileWatcherImpl( FileWatcher* parent ); - - virtual ~FileWatcherImpl(); - - /// Add a directory watch - /// On error returns WatchID with Error type. - virtual WatchID addWatch( const std::string& directory, FileWatchListener* watcher, - bool recursive ) = 0; - - /// Remove a directory watch. This is a brute force lazy search O(nlogn). - virtual void removeWatch( const std::string& directory ) = 0; - - /// Remove a directory watch. This is a map lookup O(logn). - virtual void removeWatch( WatchID watchid ) = 0; - - /// Updates the watcher. Must be called often. - virtual void watch() = 0; - - /// Handles the action - virtual void handleAction( Watcher* watch, const std::string& filename, unsigned long action, - std::string oldFilename = "" ) = 0; - - /// @return Returns a list of the directories that are being watched - virtual std::list directories() = 0; - - /// @return true if the backend init successfully - virtual bool initOK(); - - /// @return If the link is allowed according to the current path and the state of out scope - /// links - virtual bool linkAllowed( const std::string& curPath, const std::string& link ); - - /// Search if a directory already exists in the watches - virtual bool pathInWatches( const std::string& path ) = 0; - - FileWatcher* mFileWatcher; - Atomic mInitOK; - bool mIsGeneric; -}; - -} // namespace efsw - -#endif +#ifndef EFSW_FILEWATCHERIMPL_HPP +#define EFSW_FILEWATCHERIMPL_HPP + +#include +#include +#include +#include +#include +#include + +namespace efsw { + +class FileWatcherImpl { + public: + FileWatcherImpl( FileWatcher* parent ); + + virtual ~FileWatcherImpl(); + + /// Add a directory watch + /// On error returns WatchID with Error type. + virtual WatchID addWatch( const std::string& directory, FileWatchListener* watcher, + bool recursive, const std::vector& options = {} ) = 0; + + /// Remove a directory watch. This is a brute force lazy search O(nlogn). + virtual void removeWatch( const std::string& directory ) = 0; + + /// Remove a directory watch. This is a map lookup O(logn). + virtual void removeWatch( WatchID watchid ) = 0; + + /// Updates the watcher. Must be called often. + virtual void watch() = 0; + + /// Handles the action + virtual void handleAction( Watcher* watch, const std::string& filename, unsigned long action, + std::string oldFilename = "" ) = 0; + + /// @return Returns a list of the directories that are being watched + virtual std::vector directories() = 0; + + /// @return true if the backend init successfully + virtual bool initOK(); + + /// @return If the link is allowed according to the current path and the state of out scope + /// links + virtual bool linkAllowed( const std::string& curPath, const std::string& link ); + + /// Search if a directory already exists in the watches + virtual bool pathInWatches( const std::string& path ) = 0; + + protected: + friend class FileWatcher; + friend class DirWatcherGeneric; + + FileWatcher* mFileWatcher; + Atomic mInitOK; + bool mIsGeneric; + + int getOptionValue( const std::vector& options, Option option, + int defaultValue ); +}; + +} // namespace efsw + +#endif -- cgit v1.2.3-55-g6feb