@@ -63,6 +63,8 @@ class Foundation_API DirectoryWatcher: protected Runnable
6363 // / Therefore, the interval in which scans are done can be specified in
6464 // / the constructor. Note that periodic scanning will also be done on FreeBSD
6565 // / and Darwin if events for changes to files (DW_ITEM_MODIFIED) are enabled.
66+ // / To avoid problems (e.g. with network shares notifications), scanning
67+ // / can be forced as the only mechanism, regardless of platform default.
6668 // /
6769 // / DW_ITEM_MOVED_FROM and DW_ITEM_MOVED_TO events will only be reported
6870 // / on Linux. On other platforms, a file rename or move operation
@@ -134,21 +136,29 @@ class Foundation_API DirectoryWatcher: protected Runnable
134136 BasicEvent<const Exception> scanError;
135137 // / Fired when an error occurs while scanning for changes.
136138
137- DirectoryWatcher (const std::string& path, int eventMask = DW_FILTER_ENABLE_ALL , int scanInterval = DW_DEFAULT_SCAN_INTERVAL );
139+ DirectoryWatcher (const std::string& path,
140+ int eventMask = DW_FILTER_ENABLE_ALL ,
141+ int scanInterval = DW_DEFAULT_SCAN_INTERVAL ,
142+ bool forceScan = false );
138143 // / Creates a DirectoryWatcher for the directory given in path.
139144 // / To enable only specific events, an eventMask can be specified by
140145 // / OR-ing the desired event IDs (e.g., DW_ITEM_ADDED | DW_ITEM_MODIFIED).
141146 // / On platforms where no native filesystem notifications are available,
142147 // / scanInterval specifies the interval in seconds between scans
143- // / of the directory.
148+ // / of the directory. Native notification mechanism can also be disabled
149+ // / (i.e. replaced with scanning) by setting forceScan to true.
144150
145- DirectoryWatcher (const File& directory, int eventMask = DW_FILTER_ENABLE_ALL , int scanInterval = DW_DEFAULT_SCAN_INTERVAL );
151+ DirectoryWatcher (const File& directory,
152+ int eventMask = DW_FILTER_ENABLE_ALL ,
153+ int scanInterval = DW_DEFAULT_SCAN_INTERVAL ,
154+ bool forceScan = false );
146155 // / Creates a DirectoryWatcher for the specified directory
147156 // / To enable only specific events, an eventMask can be specified by
148157 // / OR-ing the desired event IDs (e.g., DW_ITEM_ADDED | DW_ITEM_MODIFIED).
149158 // / On platforms where no native filesystem notifications are available,
150159 // / scanInterval specifies the interval in seconds between scans
151- // / of the directory.
160+ // / of the directory. Native notification mechanism can also be disabled
161+ // / (i.e. replaced with scanning) by setting forceScan to true.
152162
153163 ~DirectoryWatcher ();
154164 // / Destroys the DirectoryWatcher.
@@ -186,11 +196,12 @@ class Foundation_API DirectoryWatcher: protected Runnable
186196 DirectoryWatcher (const DirectoryWatcher&);
187197 DirectoryWatcher& operator = (const DirectoryWatcher&);
188198
189- Thread _thread;
190- File _directory;
191- int _eventMask;
192- AtomicCounter _eventsSuspended;
193- int _scanInterval;
199+ Thread _thread;
200+ File _directory;
201+ int _eventMask;
202+ AtomicCounter _eventsSuspended;
203+ int _scanInterval;
204+ bool _forceScan;
194205 DirectoryWatcherStrategy* _pStrategy;
195206};
196207
0 commit comments