X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/227dee95e0c5b7e060c099329ba3d257281a24e2..b8f0ac88a51be909c0e5b87657ea0a5dc9bbb721:/include/wx/fswatcher.h diff --git a/include/wx/fswatcher.h b/include/wx/fswatcher.h index 7c6b63ef39..ebbf146734 100644 --- a/include/wx/fswatcher.h +++ b/include/wx/fswatcher.h @@ -44,15 +44,18 @@ enum wxFSW_EVENT_RENAME = 0x04, wxFSW_EVENT_MODIFY = 0x08, wxFSW_EVENT_ACCESS = 0x10, + wxFSW_EVENT_ATTRIB = 0x20, // Currently this is wxGTK-only // error events - wxFSW_EVENT_WARNING = 0x20, - wxFSW_EVENT_ERROR = 0x40, - + wxFSW_EVENT_WARNING = 0x40, + wxFSW_EVENT_ERROR = 0x80, wxFSW_EVENT_ALL = wxFSW_EVENT_CREATE | wxFSW_EVENT_DELETE | wxFSW_EVENT_RENAME | wxFSW_EVENT_MODIFY | - wxFSW_EVENT_ACCESS | + wxFSW_EVENT_ACCESS | wxFSW_EVENT_ATTRIB | wxFSW_EVENT_WARNING | wxFSW_EVENT_ERROR +#ifdef wxHAS_INOTIFY + ,wxFSW_EVENT_UNMOUNT = 0x2000 +#endif }; // Type of the path watched, used only internally for now. @@ -75,7 +78,7 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_FSWATCHER, class WXDLLIMPEXP_BASE wxFileSystemWatcherEvent: public wxEvent { public: - wxFileSystemWatcherEvent(int changeType, int watchid = wxID_ANY) : + wxFileSystemWatcherEvent(int changeType = 0, int watchid = wxID_ANY) : wxEvent(watchid, wxEVT_FSWATCHER), m_changeType(changeType) { @@ -149,7 +152,7 @@ public: virtual wxEventCategory GetEventCategory() const { - // TODO this has to be merged with "similiar" categories and changed + // TODO this has to be merged with "similar" categories and changed return wxEVT_CATEGORY_UNKNOWN; } @@ -176,6 +179,8 @@ protected: wxFileName m_path; wxFileName m_newPath; wxString m_errorMsg; +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFileSystemWatcherEvent) }; typedef void (wxEvtHandler::*wxFileSystemWatcherEventFunction) @@ -196,7 +201,7 @@ class wxFSWatchInfo { public: wxFSWatchInfo() : - m_events(-1), m_type(wxFSWPath_None) + m_events(-1), m_type(wxFSWPath_None), m_refcount(-1) { } @@ -204,7 +209,8 @@ public: int events, wxFSWPathType type, const wxString& filespec = wxString()) : - m_path(path), m_filespec(filespec), m_events(events), m_type(type) + m_path(path), m_filespec(filespec), m_events(events), m_type(type), + m_refcount(1) { } @@ -225,11 +231,27 @@ public: return m_type; } + // Reference counting of watch entries is used to avoid watching the same + // file system path multiple times (this can happen even accidentally, e.g. + // when you have a recursive watch and then decide to watch some file or + // directory under it separately). + int IncRef() + { + return ++m_refcount; + } + + int DecRef() + { + wxASSERT_MSG( m_refcount > 0, wxS("Trying to decrement a zero count") ); + return --m_refcount; + } + protected: wxString m_path; wxString m_filespec; // For tree watches, holds any filespec to apply int m_events; wxFSWPathType m_type; + int m_refcount; }; WX_DECLARE_STRING_HASH_MAP(wxFSWatchInfo, wxFSWatchInfoMap);