Add a watch on path, build a Watch object and insert it in the
        watch manager dictionary. Return the wd value.
439850
def __add_watch(self, path, mask, proc_fun, auto_add, exclude_filter):
        
        path = self.__format_path(path)
        if auto_add and not mask & IN_CREATE:
            mask |= IN_CREATE
        wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask)
        if wd < 0:
            return wd
        watch = Watch(wd=wd, path=path, mask=mask, proc_fun=proc_fun,
                      auto_add=auto_add, exclude_filter=exclude_filter)
        # wd are _always_ indexed with their original unicode paths in wmd.
        self._wmd[wd] = watch
        log.debug('New %s', watch)
        return wd
420915
def add_handler(self, path, handler):
        
        self.signatures[path] = self.get_path_signature(path)
        self.handlers[path] = handler
805439
def _add_file(self, path, **params):
        
        log = self._getparam('log', self._discard, **params)
        fd = None
        try:
            fd = os.open(path, os.O_RDONLY)
        except Exception as e:
            if not self.paths[path]:
                log.error("Open failed on watched path %r -- %s", path, e, exc_info=log.isEnabledFor(logging.DEBUG))
                raise e
            elif path in self.paths_pending:
                log.debug("path %r is still pending -- %s", path, e)
            else:
                self.paths_pending[path] = True
                log.debug("Added %r to pending list after open failure -- %s", path, e)
            return False
        if self._mode == WF_KQUEUE:
            log.debug("path %s opened as fd %d", path, fd)
            try:
                ev = select.kevent(fd,
                    filter=select.KQ_FILTER_VNODE,
                    flags=select.KQ_EV_ADD | select.KQ_EV_CLEAR,
                    fflags=select.KQ_NOTE_WRITE | select.KQ_NOTE_ATTRIB | select.KQ_NOTE_LINK |
                                select.KQ_NOTE_DELETE | select.KQ_NOTE_RENAME)
                self._kq.control([ev], 0, 0)
            except Exception as e:
                log.error("kevent failed on watched path %r -- %s", path, e)
                try: os.close(fd)
                except: pass
                raise e

        elif self._mode == WF_INOTIFYX:
            #  inotify doesn't need the target paths open, so now it is known to be
            #  accessible, close the actual fd and use the watch-descriptor as the fd.
            #
            #  However, due to an apparent simfs bug where inotify does not fire either
            #  IN_DELETE_SELF or IN_MOVE_SELF, we need to record the inode so that we
            #  can detect deletes and renames internally.  simfs is used in containers.
            #
            try:
                s = os.fstat(fd)
                self._inx_inode[path] = s.st_ino
            except Exception as e:
                log.error("fstat(%d) failed on open path %r -- %s", fd, path, e)
                try: os.close(fd)
                except: pass
                raise e
            try: os.close(fd)
            except: pass
            try:
                fd = pynotifyx.add_watch(self._inx_fd, path, self._inx_mask)
                log.debug("path %s watched with wd %d", path, fd)
            except Exception as e:
                log.error("inotify failed on watched path %r -- %s", path, e)
                raise e

        elif self._mode == WF_POLLING:
            log.debug("path %s opened as fd %d", path, fd)
            fstate = self._poll_get_stat(fd, path)
            if fstate:
                self._poll_stat[fd] = fstate

        self.paths_open[path] = fd
        self.fds_open[fd] = path
        return True
1064015
def addWatchedDirectory(self, dirname, watching=Purr.WATCHED, save_config=True):
        """"""
        # see if we're alredy watching this exact set of directories -- do nothing if so
        dirname = Purr.canonizePath(dirname)
        # do nothing if already watching
        if dirname in self.watched_dirs:
            dprint(1, "addWatchDirectory(): already watching %s\n", dirname)
            # watching=None means do not change the watch-state
            if watching is None:
                return
        else:
            if watching is None:
                watching = Purr.WATCHED
            # make watcher object
            wdir = Purrer.WatchedDir(dirname, mtime=self.timestamp,
                                     watch_patterns=self._watch_patterns, ignore_patterns=self._ignore_patterns)
            # fileset=None indicates error reading directory, so ignore it
            if wdir.fileset is None:
                print("There was an error reading the directory %s, will stop watching it." % dirname)
                self.setWatchingState(dirname, Purr.REMOVED, save_config=True)
                return
            self.watchers[dirname] = wdir
            self.watched_dirs.append(dirname)
            dprintf(2, "watching directory %s, mtime %s, %d files\n",
                    dirname, time.strftime("%x %X", time.localtime(wdir.mtime)), len(wdir.fileset))
            # find files in this directory matching the watch_patterns, and watch them for changes
            watchset = set()
            for patt in self._watch_patterns:
                watchset.update(fnmatch.filter(wdir.fileset, patt))
            for fname in watchset:
                quiet = matches_patterns(fname, self._quiet_patterns)
                fullname = Purr.canonizePath(os.path.join(dirname, fname))
                if fullname not in self.watchers:
                    wfile = Purrer.WatchedFile(fullname, quiet=quiet, mtime=self.timestamp)
                    self.watchers[fullname] = wfile
                    dprintf(3, "watching file %s, timestamp %s, quiet %d\n",
                            fullname, time.strftime("%x %X", time.localtime(wfile.mtime)), quiet)
            # find subdirectories  matching the subdir_patterns, and watch them for changes
            for fname in wdir.fileset:
                fullname = Purr.canonizePath(os.path.join(dirname, fname))
                if os.path.isdir(fullname):
                    for desc, dir_patts, canary_patts in self._subdir_patterns:
                        if matches_patterns(fname, dir_patts):
                            quiet = matches_patterns(fname, self._quiet_patterns)
                            wdir = Purrer.WatchedSubdir(fullname, canary_patterns=canary_patts, quiet=quiet,
                                                        mtime=self.timestamp)
                            self.watchers[fullname] = wdir
                            dprintf(3, "watching subdirectory %s/{%s}, timestamp %s, quiet %d\n",
                                    fullname, ",".join(canary_patts),
                                    time.strftime("%x %X", time.localtime(wdir.mtime)), quiet)
                            break
        # set state and save config
        self.setWatchingState(dirname, watching, save_config=save_config)
193244
def get(self, path, watch=None):
        
        return self._zk.get(self.__path(path), watch=watch)
1322862
def restricting_new_watches_for?(watch_type, path)
      synchronize do
        if set = @outstanding_watches[watch_type]
          return set.include?(path)
        end
      end

      false
    end
873654
public function addToWatchFolders($path, $watch_folders)
    {
        collect($watch_folders)->each(function ($folder) use ($path) {
            $this->watchFolders[] = !file_exists($new = make_path([$path, $folder])) && file_exists($folder)
                ? $folder
                : $new;
        });
    }
986490
public static WatchMonitor create(Path path, WatchEvent.Kind<?>... events){
		return create(path, 0, events);
	}
716655
def module_add(self, ev, path=None):
        
        log = self._params.get('log', self._discard)
        key = ev.get_key()
        if key is None:
            raise TaskError(name, "Attempt to register python module event with no key available")
        log.debug("Adding path %r for task %r, action %s", path, ev.get_name(), ev._handler_name)
        self._watch_modules.add(key, command_path=path)
        self._module_event_map[key] = ev
1177529
def add_watcher(watcher)

      @watchers[watcher.id] = watcher

      @dwChangeHandles.push watcher.id

      # Pack event handles into newly created storage area 
      # to be used for Win32 call
      @lp_dwChangeHandles = dwChangeHandles.pack("L" * dwChangeHandles.count)

    end
1073422
protected function addWatch()
    {
        return inotify_add_watch($this->getBag()->getInotify(), $this->getResource()->getResource(), $this->getInotifyEventMask());
    }
170380
def _watch_file(self, filepath, trigger_event=True):
        """"""
        is_new = filepath not in self._watched_files
        if trigger_event:
            if is_new:
                self.trigger_created(filepath)
            else:
                self.trigger_modified(filepath)
        try:
            self._watched_files[filepath] = self._get_modified_time(filepath)
        except OSError:
            return
367376
private void register(Path dir) throws IOException {
//        WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_MODIFY);
        WatchKey key = dir.register(watcher, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_CREATE}, SensitivityWatchEventModifier.HIGH);
        if (trace) {
            Path prev = keys.get(key);
            if (prev == null) {
                System.out.format("register: %s\n", dir);
            } else {
                if (!dir.equals(prev)) {
                    System.out.format("update: %s -> %s\n", prev, dir);
                }
            }
        }
        keys.put(key, dir);
    }
941515
private void traverse(final Path path, final boolean watch, final boolean remove) {
		log.debug("traverse start. path : {}, watch : {}, remove : {}", path, watch, remove);
		if (Files.notExists(path)) {
			return;
		}
		if (Files.isDirectory(path)) {
			if (validPath(path)) {
				try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
					if (watch) {
						WatchKey key = path.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
						watchDirs.put(key, path);
					}
					for (Path child : ds) {
						traverse(child, watch, remove);
					}
				} catch (IOException ex) {
					throw new UroborosqlRuntimeException("I/O error occured.", ex);
				}
			}
		} else if (path.toString().endsWith(fileExtension)) {
			String sqlName = getSqlName(path);
			this.sqlInfos.compute(sqlName,
					(k, v) -> v == null ? new SqlInfo(sqlName, path, dialect, charset) : v.computePath(path, remove));
		}
	}
1108817
function watch (glob, watchOpt) {
    if (!started) {
      deferredWatch = emitter.watch.bind(null, glob, watchOpt)
    } else {
      // destroy previous
      if (fileWatcher) fileWatcher.close()
      glob = glob && glob.length > 0 ? glob : defaultWatchGlob
      glob = Array.isArray(glob) ? glob : [ glob ]
      watchOpt = xtend({ poll: opts.poll }, watchOpt)

      fileWatcher = createFileWatch(glob, watchOpt)
      fileWatcher.on('watch', emitter.emit.bind(emitter, 'watch'))
    }
    return emitter
  }
494926
public static WatchMonitor createAll(String path, Watcher watcher){
		return createAll(Paths.get(path), watcher);
	}
1010732
function watchPath(path, ignored) {
    if (_watcherMap.hasOwnProperty(path)) {
        return;
    }
    return _watcherImpl.watchPath(path, ignored, _watcherMap, _domainManager);
}