Search

This class notifies the application about the file system changes by sending events of wx.FileSystemWatcherEvent class. By default these events are sent to the wx.FileSystemWatcher object itself so you can derive from it and use the event table EVT_FSWATCHER macro to handle these events in a derived class method. Alternatively, you can use wx.FileSystemWatcher.SetOwner to send the events to another object. Or you could use wx.EvtHandler.Connect with wxEVT_FSWATCHER to handle these events in any other object. See the fswatcher sample for an example of the latter approach.

New in version 2.9.1.

Note

Implementation limitations: this class is currently implemented for MSW, OS X and GTK ports but doesn’t detect all changes correctly everywhere: under MSW accessing the file is not detected (only modifying it is) and under OS X neither accessing nor modifying is detected (only creating and deleting files is). Moreover, OS X version doesn’t currently collapse pairs of create/delete events in a rename event, unlike the other ones.

This is the same as Add , but also recursively adds every file/directory in the tree rooted at path.

Additionally a file mask can be specified to include only files matching that particular mask.

This method is implemented efficiently on MSW, but should be used with care on other platforms for directories with lots of children (e.g. the root directory) as it calls Add for each subdirectory, potentially creating a lot of watches and taking a long time to execute.

Note that on platforms that use symbolic links, you will probably want to have called FileName.DontFollowLink on path. This is especially important if the symlink targets may themselves be watched.