Panoptes is a cross-platform file watcher library for C++17 using std::filesystem and native interfaces. It is tested on Linux, Windows and macOS platforms with the help of the test framework Catch2. The main target is to unify the APIs of Windows, Linux and macOS. In an earlier stage Panoptes was a fork of Axosoft nsfw.
Panoptes is observing all changes inside of a given directory. This includes add, modify or remove events. Even the changes inside of subdirectories (recursively) will be detected. Edge cases are covered too in case a file or directory will be moved in or out of the watched directory.
- Windows: ReadDirectoryChangesW
- macOS: File System Events
- Linux: inotify
- Include Panoptes to your project.
- Look into the small console example how to call and use the FileWatcher.
A conan package of the last release, can be created with the help of conanfile.py.
Instead of detecting a rename/move event, Panoptes is detecting one add and one remove event. Under Linux in general and since Windows 10, it is possible to connect the add and remove event with each other to one rename/move event. But under MacOS (10.12) it seems to be not possible, because of the internal buffer system.
macOS buffers and stashes all detected events over a given time. This means that the callback of the native API is not returning immediately after a filesystem change happens. It waits for some time and then returns a batch of events. If the underlying filesystem is HFS+ (old filesystem of macOS) the buffering time has to be at least 1 second. To unify this experience Panoptes adds a buffer system to Linux and Windows, inspired by macOS. But it would be better if we find a way for macOS to return the results directly, instead of using for every platform a buffer system. With the new macOS filesystem APFS, it is possible to set the buffering time to some nanoseconds.
- Issues and bugs can be raised on the Issue tracker on GitHub