Working demo for wxFileSystemWatcher #113
Merged
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.
Here is a simple file watcher app, as discussed on #110. Tested on Ubuntu 14.04 with PHP 5.5.9.
There are a couple of oddities I'd draw attention to, in case you want to improve this before merging down. Firstly to watch what happens inside a folder, the watched folder must end in a trailing slash - if this behaviour is introduced by wxPHP and not wxWidgets, that might be worth looking at. (I don't have a view as to where it is introduced, but thought the behaviour was rather strange - if there is no trailing slash I imagine one would still want to know about file events directly in that folder).
Also, unlike other controls a watcher cannot be instantiated until the loop is running, and creating one in a frame constructor or app init bombs with an error (see the code comments). Ideally it could be instantiated at any time and start watching when the event loop starts, but I don't know how feasible this is (and the timer workaround feels perfectly clean). If there's a better way to delay this instantiation, do let me know.