Register the given directory with the WatchService
964975
private void register(Path path, ResourceMonitorImpl monitorImpl) throws IOException
   {
      WatchKey key = path.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
      keys.put(key, monitorImpl);
   }
671070
function setupWatchers(path) {
    // We want to track the watchers now and return if we are already watching this folder
    if (watchingFolders[path]) { return; }

    watchingFolders[path] = fs.watch(path, getWatcher(path + "/"));
    watchingFolders[path].on('error', function() {  verifyWatches(); });
    var fileList = fs.readdirSync(path);
    var stats;
    for (var i = 0; i < fileList.length; i++) {
        try {
            stats = fs.statSync(path + "/" + fileList[i]);
        }
        catch (e) {
            continue;
        }
        if (isWatching(fileList[i])) {
            timeStamps[path + "/" + fileList[i]] = stats.mtime.getTime();
        } else {
            if (stats.isDirectory()) {
                if (fileList[i] === "node_modules") {
                    watchingFolders[path + "/" + fileList[i]] = true;
                    continue;
                }
                if (fileList[i] === "tns_modules") {
                    watchingFolders[path + "/" + fileList[i]] = true;
                    continue;
                }
                if (fileList[i] === "App_Resources") {
                    watchingFolders[path + "/" + fileList[i]] = true;
                    continue;
                }
                setupWatchers(path + "/" + fileList[i]);
            }
        }
    }
}
1144817
public void addWatchDirectory(File dir, List<String> fileExtensions) {
    	List<String> fileExtensionsWithoutDot = new ArrayList<String>(fileExtensions.size());
    	for(String fileExtension : fileExtensions){
    		fileExtensionsWithoutDot.add(removeStartingDotIfPresent(fileExtension));
    	}
    	directoryWatcherDelegate.addWatchDirectory(dir, fileExtensions);
    }
431652
def registerDirs(self,json_dirs):
        
        url = self._url + "/directories/registerDirs"
        params = {
            "f" : "json",
            "directories" : json_dirs
        }

        res = self._post(url=url,
                         param_dict=params,
                         securityHandler=self._securityHandler,
                         proxy_url=self._proxy_url,
                         proxy_port=self._proxy_port)

        return res
1060216
protected @Nonnull WatchKey registerPath(@Nonnull Path dir) throws IOException {
        return dir.register(watchService,
                StandardWatchEventKinds.ENTRY_CREATE,
                StandardWatchEventKinds.ENTRY_DELETE,
                StandardWatchEventKinds.ENTRY_MODIFY
        );
    }
1199276
function watchModule (module, modulesDir) {

    const pathToModule = resolve(modulesDir, module);
    const pathToHandlers = resolve(HANDLER_BASE, module);


    modules[module] = {
        handlers: []
    };
    fs.readdir(pathToHandlers, (err, files) => {

        if (err) {
            return console.log(new Error('Failed to get handler files for module: ' + module));
        }

        files.forEach(file => {

            if (file.length < 3 || file.indexOf('bundle.') === 0 || file.substr(file.length - 3) !== '.js') {
                return;
            }

            modules[module].handlers.push(pathToHandlers + '/' + file);
        });

        let watchList = modules[module].handlers.concat([pathToModule]);
        let watcher = chokidar.watch(watchList, {
            ignored: /(^|[\/\\])\../,
            persistent: true
        });
        watcher.on('change', (path, stats) => {

            // rebundle based on the type of the file
            if (modules[module].handlers.indexOf(path) < 0) {
                modules[module].handlers.forEach(handler => bundleHandler(pathToHandlers, module, handler.substr(handler.lastIndexOf('/') + 1)));
            } else {
                bundleHandler(pathToHandlers, module, path.substr(path.lastIndexOf('/') + 1));
            }
        });
    });
}
602846
function addWatcher(dirPath) {
    Debug._l(dirPath);
    /*fs.watchFile(dirPath, function (curr, prev) {
     //        console.log('the current mtime is: ' + curr.mtime);
     //        console.log('the previous mtime was: ' + prev.mtime);

     generateCache(id, dirPath);
     });*/
    var watch = Watcher(dirPath, function (filePath, isModified, isDeleted) {
        if (isModified) {
            Debug._l(generateIdFromFilePath(filePath));
            generateCache(filePath);
        }
        if (isDeleted) {
            removeCache(generateIdFromFilePath(filePath));
        }
    });

    return watch;
}
274738
def register_watchers(self, type_callback_dict, register_timeout=None):
        
        for event_type, callback in type_callback_dict.items():
            self._push_watchers[event_type].add(callback)
        self.wait_for_response(
            RegisterMessage(event_list=type_callback_dict.keys()),
            timeout=register_timeout)
487030
private void registerDirectory(Path path) {
        try {
            LOGGER.info("监控目录:" + path);
            WatchKey key = path.register(watchService, events);
            directories.put(key, path);
        } catch (IOException ex) {
            LOGGER.error("监控目录失败：" + path.toAbsolutePath(), ex);
        }
    }
575400
private File updateMonitoredDirectory(String newMonitoredFolder) {

        File oldDir = monitoredDirectory.get();
        File newDir = new File(newMonitoredFolder);

        // If it is relative, resolve against server dir
        if (!!!newDir.isAbsolute()) {
            newMonitoredFolder = locationService.resolveString(WsLocationConstants.SYMBOL_SERVER_CONFIG_DIR + newMonitoredFolder);
            newDir = new File(newMonitoredFolder);
        }

        if (!!!newDir.equals(oldDir)) {
            if (monitoredDirectory.compareAndSet(oldDir, newDir)) {
                for (ServiceReg<FileMonitor> mon : _monitors.values()) {
                    mon.unregister();
                }
                _monitors.clear();

                if (!!!newDir.exists()) {
                    createdMonitoredDir.set(newDir.mkdirs());
                }
            } else {
                oldDir = null;
            }
        } else {
            oldDir = null;
        }

        return oldDir;
    }
847765
function getWatches (directory) {
  var package_path = resolve(directory || './')
  var pkg = read(package_path)
  var watches = extract(pkg)
  return Array.isArray(watches) ? watches : []
}
139401
@Deprecated
    public void addWatcher(Path file, Watcher watcher) {
        addWatcher(file, (Listener) watcher);
    }
479856
@SuppressWarnings("unchecked")
    private <T> List<WatcherRegistration<T>> getWatcherRegistrations(Id<T> id) {
        return (List<WatcherRegistration<T>>)((Container)watcherRegistry).getAll(id.type());
    }
701543
public function register()
    {
    	$this->app->singleton('watcher', function ($app) {
            return new Watcher(new Tracker, $app['files']);
        });

        $this->app->alias('watcher', 'JasonLewis\ResourceWatcher\Watcher');
    }
891111
private void deployWatcher(Object target, Method method, String watchedKey) throws Exception {

        configurationUtil.subscribe(watchedKey, (key, value) -> {

            if (Objects.equals(watchedKey, key)) {

                try {
                    if (String.class.equals(method.getParameters()[0].getType())) {
                        method.invoke(target, value);
                    } else if (Boolean.class.equals(method.getParameters()[0].getType()) || boolean.class.equals(method
                            .getParameters()[0].getType())) {
                        method.invoke(target, Boolean.parseBoolean(value));
                    } else if (Float.class.equals(method.getParameters()[0].getType()) || float.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Float.parseFloat(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. " +
                                    "Expected: Float. Value: " + value);
                        }
                    } else if (Double.class.equals(method.getParameters()[0].getType()) || double.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Double.parseDouble(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. Expected:" +
                                    " Double. Value: " + value);
                        }
                    } else if (Integer.class.equals(method.getParameters()[0].getType()) || int.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Integer.parseInt(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. Expected:" +
                                    " Integer. Value: " + value);
                        }
                    } else if (Long.class.equals(method.getParameters()[0].getType()) || long.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Long.parseLong(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. Expected:" +
                                    " Long. Value: " + value);
                        }
                    }
                } catch (IllegalAccessException e) {
                    log.severe("Illegal access exception: " + e.toString());
                } catch (InvocationTargetException e) {
                    log.severe("Invocation target exception: " + e.toString());
                }

            }
        });
    }
445287
def register_click_watcher(self, watcher_name, selectors, *condition_list):
        
        watcher = self.device.watcher(watcher_name)
        for condition in condition_list:
            watcher.when(**self.__unicode_to_dict(condition))
        watcher.click(**self.__unicode_to_dict(selectors))
        self.device.watchers.run()
972850
def execute_watch(self, id=None, body=None, params=None):
        
        return self.transport.perform_request(
            "PUT",
            _make_path("_watcher", "watch", id, "_execute"),
            params=params,
            body=body,
        )