/////////////////////////////////////////////////////////////////////////////
-// Name: common/fswatchercmn.cpp
+// Name: src/common/fswatchercmn.cpp
// Purpose: wxMswFileSystemWatcher
// Author: Bartosz Bekier
// Created: 2009-05-26
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;
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;