If the event affects a directory and the auto_add flag of the
        targetted watch is set to True, a new watch is added on this
        new directory, with the same attribute values than those of
        this watch.
481854
def process_IN_CREATE(self, raw_event):
        
        if raw_event.mask & IN_ISDIR:
            watch_ = self._watch_manager.get_watch(raw_event.wd)
            created_dir = os.path.join(watch_.path, raw_event.name)
            if watch_.auto_add and not watch_.exclude_filter(created_dir):
                addw = self._watch_manager.add_watch
                # The newly monitored directory inherits attributes from its
                # parent directory.
                addw_ret = addw(created_dir, watch_.mask,
                                proc_fun=watch_.proc_fun,
                                rec=False, auto_add=watch_.auto_add,
                                exclude_filter=watch_.exclude_filter)

                # Trick to handle mkdir -p /d1/d2/t3 where d1 is watched and
                # d2 and t3 (directory or file) are created.
                # Since the directory d2 is new, then everything inside it must
                # also be new.
                created_dir_wd = addw_ret.get(created_dir)
                if ((created_dir_wd is not None) and (created_dir_wd > 0) and
                    os.path.isdir(created_dir)):
                    try:
                        for name in os.listdir(created_dir):
                            inner = os.path.join(created_dir, name)
                            if self._watch_manager.get_wd(inner) is not None:
                                continue
                            # Generate (simulate) creation events for sub-
                            # directories and files.
                            if os.path.isfile(inner):
                                # symlinks are handled as files.
                                flags = IN_CREATE
                            elif os.path.isdir(inner):
                                flags = IN_CREATE | IN_ISDIR
                            else:
                                # This path should not be taken.
                                continue
                            rawevent = _RawEvent(created_dir_wd, flags, 0, name)
                            self._notifier.append_event(rawevent)
                    except OSError, err:
                        msg = "process_IN_CREATE, invalid directory %s: %s"
                        log.debug(msg % (created_dir, str(err)))
        return self.process_default(raw_event)
1325420
private synchronized void doAddRoot(final WatchedDirectory pWatchedDirectory) {
        final Object key = requireNonNull(pWatchedDirectory.getKey(), KEY_IS_NULL);
        final Path directory = requireNonNull(pWatchedDirectory.getDirectory(), DIRECTORY_IS_NULL);

        if (!isDirectory(directory)) {
            throw new IllegalArgumentException(format("[%s]: %s is not a directory!", key, directory));
        }

        // Insure that the directory-key is unique
        if (watchedDirectories.containsKey(key)) {
            throw new IllegalArgumentException(format("Key %s already used by %s", key, watchedDirectories.get(key)));
        }
        watchedDirectories.put(key, pWatchedDirectory);

        try {
            children.computeIfAbsent(directory.getFileSystem(),
                    this::newDedicatedFileSystem).registerRootDirectory(pWatchedDirectory);
            pWatchedDirectory.addObserver(this);
            LOG.info("Added [{}:{}]", key, directory);
        } catch (final IOException | UncheckedIOException e) {
            LOG.warn(e.getMessage(), e);
        }
    }
436303
@Override
	public void onSimonCreated(Simon simon) {
		if (simon instanceof Stopwatch) {
			simon.setAttribute(timelineAttributeName, new StopwatchTimeline(timelineCapacity, timeRangeWidth));
		}
	}
989769
function checkForChangedFolders(dir) {
    var fileList = fs.readdirSync(dir);
    for (var i = 0; i < fileList.length; i++) {
        if (!fs.existsSync(dir+fileList[i])) { continue; }
        var dirStat;
        try {
            dirStat = fs.statSync(dir + fileList[i]);
        } catch (e) {
            // This means the file disappeared between the exists and us stating the file.
            continue;
        }
        if (dirStat.isDirectory()) {
            if (!watchingFolders[dir + fileList[i]]) {
                console.log("Adding new directory to watch: ", dir + fileList[i]);
                setupWatchers(dir + fileList[i]);
            }
        }
    }
}
581125
public void exists(String path, boolean watch, StatCallback cb, Object ctx) {
        exists(path, watch ? watchManager.defaultWatcher : null, cb, ctx);
    }
1031428
@Override
	public void onSimonCreated(Simon simon) {
		if (simon instanceof Stopwatch) {
			Stopwatch stopwatch = (Stopwatch) simon;
			getOrCreateBucketsValues(stopwatch);
		}
	}
868439
function watchChanges(io, params) {
    const folder = process.cwd();
    return watch(folder, { recursive: true }, () => {
        emitInfo('changes detected. Recompiling...');
        io.sockets.emit('load');
        const start = new Date().getTime();
        executeWithParams(params)
            .tap(alerts => {
                const ellapsed = new Date().getTime() - start;
                emitSuccess(`wow! recompiled and executed in ${ellapsed}ms!`);
                io.sockets.emit('update', compileMarkdown(alerts));
            })
            .catch(err => {
                emitError(`hot compilation error, baby: ${err.message}`);
                io.sockets.emit('failure', err.stack);
            });
    });
}
114004
def add_watcher(self, fd, callback):
        """"""

        if not isinstance(fd, int):
            fd = fd.fileno()

        self.callbacks[fd] = callback
        self.epoll.register(fd, EPOLLIN)
578083
def on_modified(self, event):
        
        logger.debug("file modified: %s", event.src_path)
        if not event.is_directory:
            self.update_file(event.src_path)
1139094
function watch(arg_src_dir)
{
	console.info('Watching for change on: ' + arg_src_dir)
	
	const watch_settings = { ignored: /[\/\\]\./, persistent: true }
	var watcher = chokidar.watch(arg_src_dir, watch_settings)
	watcher.on('change', reload_file)
	
	return watcher
}
1004835
def add_flag(self, flag):
        
        super(Entry, self).add_flag(flag)
        self._changed_attrs.add('flags')
1310637
def ack_watch(self, watch_id, action_id=None, params=None):
        
        if watch_id in SKIP_IN_PATH:
            raise ValueError("Empty value passed for a required argument 'watch_id'.")
        return self.transport.perform_request(
            "PUT",
            _make_path("_watcher", "watch", watch_id, "_ack", action_id),
            params=params,
        )
1003854
def _notify_add(self, slice_):
        """"""
        change = AddChange(self, slice_)
        self.notify_observers(change)
1214357
public void addWatcher(Path file, Listener watcher) {
        if (file == null) throw new IllegalArgumentException("Null file argument");
        if (watcher == null) throw new IllegalArgumentException("Null watcher argument");
        synchronized (mutex) {
            startWatchingInternal(file).add(() -> watcher);
        }
    }
32042
def run(monitor, directory, *flags, &block)
      result = watch_and_run(monitor, 1, false, directory, *flags, &block)
      result.changes[0].directory = result.directory
      result.changes[0]
    end
57020
def process_IN_MOVED_TO(self, raw_event):
        
        watch_ = self._watch_manager.get_watch(raw_event.wd)
        path_ = watch_.path
        dst_path = os.path.normpath(os.path.join(path_, raw_event.name))
        mv_ = self._mv_cookie.get(raw_event.cookie)
        to_append = {'cookie': raw_event.cookie}
        if mv_ is not None:
            self._mv[mv_[0]] = (dst_path, datetime.now())
            # Let's assume that IN_MOVED_FROM event is always queued before
            # that its associated (they share a common cookie) IN_MOVED_TO
            # event is queued itself. It is then possible in that scenario
            # to provide as additional information to the IN_MOVED_TO event
            # the original pathname of the moved file/directory.
            to_append['src_pathname'] = mv_[0]
        elif (raw_event.mask & IN_ISDIR and watch_.auto_add and
              not watch_.exclude_filter(dst_path)):
            # We got a diretory that's "moved in" from an unknown source and
            # auto_add is enabled. Manually add watches to the inner subtrees.
            # The newly monitored directory inherits attributes from its
            # parent directory.
            self._watch_manager.add_watch(dst_path, watch_.mask,
                                          proc_fun=watch_.proc_fun,
                                          rec=True, auto_add=True,
                                          exclude_filter=watch_.exclude_filter)
        return self.process_default(raw_event, to_append)
1138539
function () {
    scan_mode = false;
    log.i('Now start qiniu watch.'.yellow);
    var watcher = chokidar.watch(local_dir, {ignored: /[\/\\]\./, persistent: true});
   
    watcher.on('add', function(file, event) {
        
        var name = path.join(dirPrefix, file.replace(local_dir, '')).replace(/\\/g, '/').replace(/^\//g, '');
        check_upload(file, name);
    });
   
    watcher.on('change', function(file, event) {
        
        var name2 = path.join(dirPrefix, file.replace(local_dir, '')).replace(/\\/g, '/').replace(/^\//g, '');
        check_upload(file, name2);
    });
}