|
Gin
|
Cross-platform file system watcher for monitoring folder changes. More...
#include <gin_filesystemwatcher.h>
Classes | |
| class | Listener |
| Listener interface for receiving file system change notifications. More... | |
Public Types | |
| enum | FileSystemEvent { undefined , fileCreated , fileDeleted , fileUpdated , fileRenamedOldName , fileRenamedNewName } |
| File system event types for change notifications. More... | |
Public Member Functions | |
| FileSystemWatcher () | |
| ~FileSystemWatcher () | |
| void | coalesceEvents (int windowMS) |
| All events that arrive withing the time window for a particular file will be coalesced into one event with the type of the most recent event. | |
| void | addFolder (const juce::File &folder) |
| Adds a folder to be watched. | |
| void | removeFolder (const juce::File &folder) |
| Removes a folder from being watched. | |
| void | removeAllFolders () |
| Removes all folders from being watched. | |
| juce::Array< juce::File > | getWatchedFolders () |
| Gets a list of folders being watched. | |
| void | addListener (Listener *newListener) |
| Registers a listener to be told when things happen to the text. | |
| void | removeListener (Listener *listener) |
| Deregisters a listener. | |
Cross-platform file system watcher for monitoring folder changes.
FileSystemWatcher provides real-time notifications when files are created, modified, deleted, or renamed in watched folders. It uses platform-specific APIs (FSEvents on macOS, ReadDirectoryChangesW on Windows, inotify on Linux) for efficient monitoring without polling.
Key Features:
Platform Differences:
Event Coalescing: The watcher can coalesce multiple events for the same file within a time window into a single event, reducing callback overhead when files change rapidly (e.g., during a build process or file copy).
Usage:
Thread Safety:
File system event types for change notifications.
FileSystemEvent describes what happened to a file in a watched folder. Rename events generate two separate callbacks: one with fileRenamedOldName for the original filename, and one with fileRenamedNewName for the new filename.
Events:
Note: Rename operations typically generate two events:
| FileSystemWatcher::FileSystemWatcher | ( | ) |
| FileSystemWatcher::~FileSystemWatcher | ( | ) |
All events that arrive withing the time window for a particular file will be coalesced into one event with the type of the most recent event.
Removes a folder from being watched.
| void FileSystemWatcher::removeAllFolders | ( | ) |
Removes all folders from being watched.
| juce::Array< juce::File > FileSystemWatcher::getWatchedFolders | ( | ) |
Gets a list of folders being watched.
Registers a listener to be told when things happen to the text.
Deregisters a listener.