Version: 2.9.4
Public Member Functions
wxFileSystemWatcher Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/fswatcher.h>

Inheritance diagram for wxFileSystemWatcher:

Detailed Description

The wxFileSystemWatcher class allows to receive notifications of file system changes.

注:
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.

For the full list of change types that are reported see wxFSWFlags.

This class notifies the application about the file system changes by sending events of wxFileSystemWatcherEvent class. By default these events are sent to the wxFileSystemWatcher 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 wxFileSystemWatcher::SetOwner() to send the events to another object. Or you could use wxEvtHandler::Connect() with wxEVT_FSWATCHER to handle these events in any other object. See the fswatcher sample for an example of the latter approach.

Library:  wxBase
Category:  File Handling
Since:
2.9.1

Public Member Functions

 wxFileSystemWatcher ()
 Default constructor.
virtual ~wxFileSystemWatcher ()
 Destructor.
virtual bool Add (const wxFileName &path, int events=wxFSW_EVENT_ALL)
 Adds path to currently watched files.
virtual bool AddTree (const wxFileName &path, int events=wxFSW_EVENT_ALL, const wxString &filter=wxEmptyString)
 This is the same as Add(), but recursively adds every file/directory in the tree rooted at path.
virtual bool Remove (const wxFileName &path)
 Removes path from the list of watched paths.
virtual bool RemoveTree (const wxFileName &path)
 Same as Remove(), but also removes every file/directory belonging to the tree rooted at path.
virtual bool RemoveAll ()
 Clears the list of currently watched paths.
int GetWatchedPathsCount () const
 Returns the number of currently watched paths.
int GetWatchedPaths (wxArrayString *paths) const
 Retrieves all watched paths and places them in paths.
void SetOwner (wxEvtHandler *handler)
 Associates the file system watcher with the given handler object.

List of all members.


Constructor & Destructor Documentation

wxFileSystemWatcher::wxFileSystemWatcher ( )

Default constructor.

virtual wxFileSystemWatcher::~wxFileSystemWatcher ( ) [virtual]

Destructor.

Stops all paths from being watched and frees any system resources used by this file system watcher object.


Member Function Documentation

virtual bool wxFileSystemWatcher::Add ( const wxFileName path,
int  events = wxFSW_EVENT_ALL 
) [virtual]

Adds path to currently watched files.

The path argument can currently only be a directory and any changes to this directory itself or its immediate children will generate the events. Use AddTree() to monitor the directory recursively.

Parameters:
pathThe name of the path to watch.
eventsAn optional filter to receive only events of particular types.
virtual bool wxFileSystemWatcher::AddTree ( const wxFileName path,
int  events = wxFSW_EVENT_ALL,
const wxString filter = wxEmptyString 
) [virtual]

This is the same as Add(), but 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 under MSW but shouldn't be used for the directories with a lot of children (such as e.g. the root directory) under the other platforms as it calls Add() there for each subdirectory potentially creating a lot of watches and taking a long time to execute.

int wxFileSystemWatcher::GetWatchedPaths ( wxArrayString paths) const

Retrieves all watched paths and places them in paths.

Returns the number of watched paths, which is also the number of entries added to paths.

int wxFileSystemWatcher::GetWatchedPathsCount ( ) const

Returns the number of currently watched paths.

参照:
GetWatchedPaths()
virtual bool wxFileSystemWatcher::Remove ( const wxFileName path) [virtual]

Removes path from the list of watched paths.

virtual bool wxFileSystemWatcher::RemoveAll ( ) [virtual]

Clears the list of currently watched paths.

virtual bool wxFileSystemWatcher::RemoveTree ( const wxFileName path) [virtual]

Same as Remove(), but also removes every file/directory belonging to the tree rooted at path.

void wxFileSystemWatcher::SetOwner ( wxEvtHandler handler)

Associates the file system watcher with the given handler object.

All the events generated by this object will be passed to the specified owner.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines