]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fswatchercmn.cpp
adapting to init pattern
[wxWidgets.git] / src / common / fswatchercmn.cpp
index 1f8946be9e848a311850b700d361d26d7975afc0..73a608c45090781678a85ba4c7ac5b9442f71a13 100644 (file)
@@ -79,10 +79,30 @@ wxFileSystemWatcherBase::~wxFileSystemWatcherBase()
 
 bool wxFileSystemWatcherBase::Add(const wxFileName& path, int events)
 {
-    // args validation & consistency checks
-    if (!path.FileExists() && !path.DirExists())
+    wxFSWPathType type = wxFSWPath_None;
+    if ( path.FileExists() )
+    {
+        type = wxFSWPath_File;
+    }
+    else if ( path.DirExists() )
+    {
+        type = wxFSWPath_Dir;
+    }
+    else
+    {
+        wxLogError(_("Can't monitor non-existent path \"%s\" for changes."),
+                   path.GetFullPath());
         return false;
+    }
 
+    return DoAdd(path, events, type);
+}
+
+bool
+wxFileSystemWatcherBase::DoAdd(const wxFileName& path,
+                               int events,
+                               wxFSWPathType type)
+{
     wxString canonical = GetCanonicalPath(path);
     if (canonical.IsEmpty())
         return false;
@@ -91,7 +111,7 @@ bool wxFileSystemWatcherBase::Add(const wxFileName& path, int events)
                 wxString::Format("Path '%s' is already watched", canonical));
 
     // adding a path in a platform specific way
-    wxFSWatchInfo watch(canonical, events);
+    wxFSWatchInfo watch(canonical, events, type);
     if ( !m_service->Add(watch) )
         return false;