X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/906c935a80b10d53cecf57f71ab5f3f4f1d529ec..319faba717040fd0af134f4a36fba3f0b8e284ab:/src/common/fswatchercmn.cpp diff --git a/src/common/fswatchercmn.cpp b/src/common/fswatchercmn.cpp index 73a608c450..7382c2f6fb 100644 --- a/src/common/fswatchercmn.cpp +++ b/src/common/fswatchercmn.cpp @@ -95,13 +95,13 @@ bool wxFileSystemWatcherBase::Add(const wxFileName& path, int events) return false; } - return DoAdd(path, events, type); + return AddAny(path, events, type); } bool -wxFileSystemWatcherBase::DoAdd(const wxFileName& path, - int events, - wxFSWPathType type) +wxFileSystemWatcherBase::AddAny(const wxFileName& path, + int events, + wxFSWPathType type) { wxString canonical = GetCanonicalPath(path); if (canonical.IsEmpty()) @@ -159,17 +159,22 @@ bool wxFileSystemWatcherBase::AddTree(const wxFileName& path, int events, // all of them to Add() and let it choose? this is useful when adding a // file to a dir that is already watched, then not only should we know // about that, but Add() should also behave well then - virtual wxDirTraverseResult OnFile(const wxString& WXUNUSED(filename)) + virtual wxDirTraverseResult OnFile(const wxString& filename) { + wxLogTrace(wxTRACE_FSWATCHER, + "--- AddTree adding file '%s' ---", filename); + m_watcher->AddAny(wxFileName::FileName(filename), + m_events, wxFSWPath_File); return wxDIR_CONTINUE; } virtual wxDirTraverseResult OnDir(const wxString& dirname) { - wxLogTrace(wxTRACE_FSWATCHER, "--- AddTree adding '%s' ---", - dirname); + wxLogTrace(wxTRACE_FSWATCHER, + "--- AddTree adding directory '%s' ---", dirname); // we add as much as possible and ignore errors - m_watcher->Add(wxFileName(dirname), m_events); + m_watcher->AddAny(wxFileName::DirName(dirname), + m_events, wxFSWPath_Dir); return wxDIR_CONTINUE; } @@ -183,6 +188,9 @@ bool wxFileSystemWatcherBase::AddTree(const wxFileName& path, int events, AddTraverser traverser(this, events); dir.Traverse(traverser, filter); + // Add the path itself explicitly as Traverse() doesn't return it. + Add(path.GetPathWithSep(), events); + return true; } @@ -209,7 +217,7 @@ bool wxFileSystemWatcherBase::RemoveTree(const wxFileName& path) virtual wxDirTraverseResult OnDir(const wxString& dirname) { - m_watcher->RemoveTree(wxFileName(dirname)); + m_watcher->Remove(wxFileName::DirName(dirname)); return wxDIR_CONTINUE; } @@ -221,6 +229,9 @@ bool wxFileSystemWatcherBase::RemoveTree(const wxFileName& path) RemoveTraverser traverser(this); dir.Traverse(traverser); + // As in AddTree() above, handle the path itself explicitly. + Remove(path); + return true; }