-
Notifications
You must be signed in to change notification settings - Fork 73
File system watcher #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
9e2a31b
Fix comments in FileIterator
sbusch42 0b91777
Make filesystem accessible through interfaces (FileHandle, FileIterator)
sbusch42 299d797
Create structure for file system watchers and first implementation fo…
sbusch42 9d08a58
Remove clone() from file watcher interface
sbusch42 89e4dd8
Create file event handlers (analog to FileVisitor)
sbusch42 a8b0d3d
Finish file watcher interface
sbusch42 ea51205
Add mode to watch files/directories recursively
sbusch42 85a6575
Clean up file watcher interface
sbusch42 2f068b1
Clean up file watcher interface
sbusch42 79b88ec
Create convenience function for creating a watcher on a single file/d…
sbusch42 2fad581
Fix FileHandle::watch() in case of other file systems than the system…
sbusch42 773cb63
Remove bit field logic where not necessary
sbusch42 9d2cf4e
Fix handling empty name field (happens when the watched object itself…
sbusch42 ca00053
Adds windows file watcher, updates watch function prototype
022be82
Windows add of folder to watch is now thread safe
f24bba7
Merge pull request #22 from robiwano/watcher
sbusch42 e363bb0
Small style related changes
sbusch42 f8b16fd
cppfs-watch: As file watchers are only available for the local file s…
sbusch42 f3c27ff
cppfs-watch: use single threading in example
sbusch42 d8cf3ce
Clarify in interface and documentation that only directories can be w…
sbusch42 60c8fb1
Remove null implementation of FileWatcher, check for backend nullptr …
sbusch42 b45312a
Move LocalFileWatcher to linux directory, as it is specific for Linux
sbusch42 b55db4a
Implement new event type FileAttribChanged
sbusch42 4ff0fa4
cppfs-watch: allow multiple paths to be specified and add --recursive…
sbusch42 cd2fabd
Fix compilation on Windows
sbusch42 dc0ebb5
Windows backend: add handling renaming of files and creating and
sbusch42 68c41aa
Review, clean up and comment Windows file watcher implementation
sbusch42 e2f78b6
Adjust contributors list
sbusch42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
|
||
Stefan Buschmann <[email protected]> <[email protected]> | ||
Daniel Limberger <[email protected]> <[email protected]> | ||
Daniel Limberger <[email protected]> <[email protected]> | ||
Willy Scheibel <[email protected]> <[email protected]> | ||
|
||
Thanks to all Contributors | ||
|
||
Thanks to all Contributors: | ||
|
||
Robert Bielik (https://github.com/robiwano) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
source/cppfs/include/cppfs/AbstractFileWatcherBackend.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
|
||
#pragma once | ||
|
||
|
||
#include <memory> | ||
|
||
#include <cppfs/cppfs.h> | ||
|
||
|
||
namespace cppfs | ||
{ | ||
|
||
|
||
class FileHandle; | ||
class FileWatcher; | ||
class AbstractFileSystem; | ||
|
||
|
||
/** | ||
* @brief | ||
* Interface for file watchers | ||
*/ | ||
class CPPFS_API AbstractFileWatcherBackend | ||
{ | ||
friend class FileWatcher; | ||
|
||
|
||
public: | ||
/** | ||
* @brief | ||
* Constructor | ||
* | ||
* @param[in] fileWatcher | ||
* File watcher that owns the backend (must NOT be null!) | ||
*/ | ||
AbstractFileWatcherBackend(FileWatcher * fileWatcher); | ||
|
||
/** | ||
* @brief | ||
* Destructor | ||
*/ | ||
virtual ~AbstractFileWatcherBackend(); | ||
|
||
/** | ||
* @brief | ||
* Get file system | ||
* | ||
* @return | ||
* File system (must NOT be null) | ||
*/ | ||
virtual AbstractFileSystem * fs() const = 0; | ||
|
||
/** | ||
* @brief | ||
* Watch directory | ||
* | ||
* @param[in] dir | ||
* Handle to directory that shall be watched | ||
* @param[in] events | ||
* Events that are watched (combination of FileEvent values) | ||
* @param[in] recursive | ||
* Watch file system recursively? | ||
*/ | ||
virtual void add(FileHandle & dir, unsigned int events, RecursiveMode recursive) = 0; | ||
|
||
/** | ||
* @brief | ||
* Start watching files | ||
* | ||
* @param[in] timeout | ||
* Timeout value in milliseconds. If less than zero, timeout is infinite and the function blocks. | ||
* | ||
* @remarks | ||
* This function shall watch the file system and block until one or more | ||
* events have occured, or if the timeout has been exceeded (timeout >= 0). | ||
* For each event, onFileEvent has to be called with the type of the event and | ||
* a file handle to the file or directory. After all events have been | ||
* processed, the function shall return. | ||
*/ | ||
virtual void watch(int timeout) = 0; | ||
|
||
|
||
protected: | ||
/** | ||
* @brief | ||
* Called on each file event | ||
* | ||
* @param[in] fh | ||
* File handle | ||
* @param[in] event | ||
* Type of event that has occured | ||
*/ | ||
void onFileEvent(FileHandle & fh, FileEvent event); | ||
|
||
|
||
protected: | ||
FileWatcher * m_fileWatcher; ///< File watcher that owns the backend (never null) | ||
}; | ||
|
||
|
||
} // namespace cppfs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
|
||
#pragma once | ||
|
||
|
||
#include <cppfs/cppfs.h> | ||
|
||
|
||
namespace cppfs | ||
{ | ||
|
||
|
||
class FileHandle; | ||
|
||
|
||
/** | ||
* @brief | ||
* Handler that is informed about file system events | ||
* | ||
* @remarks | ||
* Use FileWatcher to register file event handlers. | ||
*/ | ||
class CPPFS_API FileEventHandler | ||
{ | ||
friend class FileWatcher; | ||
|
||
|
||
public: | ||
/** | ||
* @brief | ||
* Constructor | ||
*/ | ||
FileEventHandler(); | ||
|
||
/** | ||
* @brief | ||
* Destructor | ||
*/ | ||
virtual ~FileEventHandler(); | ||
|
||
|
||
protected: | ||
/** | ||
* @brief | ||
* Called on file event | ||
* | ||
* @param[in] fh | ||
* Handle to file or directory | ||
* @param[in] event | ||
* Type of event that has occured | ||
*/ | ||
virtual void onFileEvent(FileHandle & fh, FileEvent event); | ||
|
||
/** | ||
* @brief | ||
* Called when a file or directory has been created | ||
* | ||
* @param[in] fh | ||
* Handle to file or directory | ||
*/ | ||
virtual void onFileCreated(FileHandle & fh); | ||
|
||
/** | ||
* @brief | ||
* Called when a file or directory has been removed | ||
* | ||
* @param[in] fh | ||
* Handle to file or directory | ||
*/ | ||
virtual void onFileRemoved(FileHandle & fh); | ||
|
||
/** | ||
* @brief | ||
* Called when a file or directory has been modified | ||
* | ||
* @param[in] fh | ||
* Handle to file or directory | ||
*/ | ||
virtual void onFileModified(FileHandle & fh); | ||
|
||
/** | ||
* @brief | ||
* Called when file attributes have been modified | ||
* | ||
* @param[in] fh | ||
* Handle to file or directory | ||
*/ | ||
virtual void onFileAttrChanged(FileHandle & fh); | ||
}; | ||
|
||
|
||
} // namespace cppfs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.