]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/private/fswatcher.h
Traditional Chinese translations update from Wei-Lun Chao.
[wxWidgets.git] / include / wx / private / fswatcher.h
index 286fba854728c3eeb17e8ad9d0f296e67f47a1a7..4b7a894428a1505bda5ba19c0890e5f7683a91e0 100644 (file)
@@ -23,7 +23,7 @@
     #define wxFSWatchEntry wxFSWatchEntryKq
     WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxFSWatchEntry>,wxFSWatchEntries);
     #include "wx/unix/private/fswatcher_kqueue.h"
-#elif defined(__WXMSW__)
+#elif defined(__WINDOWS__)
     class wxFSWatchEntryMSW;
     #define wxFSWatchEntry wxFSWatchEntryMSW
     WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxFSWatchEntry>,wxFSWatchEntries);
@@ -49,10 +49,15 @@ public:
 
     virtual bool Add(const wxFSWatchInfo& winfo)
     {
-        wxCHECK_MSG( m_watches.find(winfo.GetPath()) == m_watches.end(), false,
-                     "Path '%s' is already watched");
-
-        // conctruct watch entry
+        if ( m_watches.find(winfo.GetPath()) != m_watches.end() )
+        {
+            wxLogTrace(wxTRACE_FSWATCHER,
+                       "Path '%s' is already watched", winfo.GetPath());
+            // This can happen if a dir is watched, then a parent tree added
+            return true;
+        }
+
+        // construct watch entry
         wxSharedPtr<wxFSWatchEntry> watch(new wxFSWatchEntry(winfo));
 
         if (!DoAdd(watch))
@@ -66,8 +71,13 @@ public:
     virtual bool Remove(const wxFSWatchInfo& winfo)
     {
         wxFSWatchEntries::iterator it = m_watches.find(winfo.GetPath());
-        wxCHECK_MSG( it != m_watches.end(), false, "Path '%s' is not watched");
-
+        if ( it == m_watches.end() )
+        {
+            wxLogTrace(wxTRACE_FSWATCHER,
+                       "Path '%s' is not watched", winfo.GetPath());
+            // This can happen if a dir is watched, then a parent tree added
+            return true;
+        }
         wxSharedPtr<wxFSWatchEntry> watch = it->second;
         m_watches.erase(it);
         return DoRemove(watch);
@@ -79,6 +89,12 @@ public:
         return true;
     }
 
+    // Check whether any filespec matches the file's ext (if present)
+    bool MatchesFilespec(const wxFileName& fn, const wxString& filespec) const
+    {
+        return filespec.empty() || wxMatchWild(filespec, fn.GetFullName());
+    }
+
 protected:
     virtual bool DoAdd(wxSharedPtr<wxFSWatchEntry> watch) = 0;