return "MODIFY";
case wxFSW_EVENT_ACCESS:
return "ACCESS";
+ case wxFSW_EVENT_ATTRIB: // Currently this is wxGTK-only
+ return "ATTRIBUTE";
+#ifdef wxHAS_INOTIFY
+ case wxFSW_EVENT_UNMOUNT: // Currently this is wxGTK-only
+ return "UNMOUNT";
+#endif
+ case wxFSW_EVENT_WARNING:
+ return "WARNING";
+ case wxFSW_EVENT_ERROR:
+ return "ERROR";
}
// should never be reached!
// wxFileSystemWatcherEvent implementation
// ============================================================================
+IMPLEMENT_DYNAMIC_CLASS(wxFileSystemWatcherEvent, wxEvent);
+
wxString wxFileSystemWatcherEvent::ToString() const
{
return wxString::Format("FSW_EVT type=%d (%s) path='%s'", m_changeType,
}
else
{
- wxLogError(_("Can't monitor non-existent path \"%s\" for changes."),
+ // Don't overreact to being passed a non-existent item. It may have
+ // only just been deleted, in which case doing nothing is correct
+ wxLogTrace(wxTRACE_FSWATCHER,
+ "Can't monitor non-existent path \"%s\" for changes.",
path.GetFullPath());
return false;
}
if ( it == m_watches.end() )
{
wxFSWatchInfoMap::value_type val(canonical, watch);
- m_watches.insert(val).second;
+ m_watches.insert(val);
}
else
{
};
wxDir dir(path.GetFullPath());
+ // Prevent asserts or infinite loops in trees containing symlinks
+ int flags = wxDIR_DIRS;
+ if ( !path.ShouldFollowLink() )
+ {
+ flags |= wxDIR_NO_FOLLOW;
+ }
AddTraverser traverser(this, events, filespec);
- dir.Traverse(traverser, filespec);
+ dir.Traverse(traverser, filespec, flags);
// Add the path itself explicitly as Traverse() doesn't return it.
AddAny(path.GetPathWithSep(), events, wxFSWPath_Tree, filespec);
#endif // __WINDOWS__
wxDir dir(path.GetFullPath());
+ // AddTree() might have used the wxDIR_NO_FOLLOW to prevent asserts or
+ // infinite loops in trees containing symlinks. We need to do the same
+ // or we'll try to remove unwatched items. Let's hope the caller used
+ // the same ShouldFollowLink() setting as in AddTree()...
+ int flags = wxDIR_DIRS;
+ if ( !path.ShouldFollowLink() )
+ {
+ flags |= wxDIR_NO_FOLLOW;
+ }
RemoveTraverser traverser(this, filespec);
- dir.Traverse(traverser, filespec);
+ dir.Traverse(traverser, filespec, flags);
// As in AddTree() above, handle the path itself explicitly.
Remove(path);