diff options
author | Nick Simmons <nick.simmons@jadedpixel.com> | 2013-10-21 22:08:28 -0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-10-31 01:13:44 +0400 |
commit | 691b9ebc8c99acce9e8a57373b2b0daae3eadba0 (patch) | |
tree | 556a0ea0508f895be35d225a68cccee5f2a35aa1 /lib/fs.js | |
parent | bae4c907bcaa728d81ee8c264be1bafba9a45b71 (diff) | |
download | nodejs-691b9ebc8c99acce9e8a57373b2b0daae3eadba0.tar.gz nodejs-691b9ebc8c99acce9e8a57373b2b0daae3eadba0.tar.bz2 nodejs-691b9ebc8c99acce9e8a57373b2b0daae3eadba0.zip |
fs: add recursive subdirectory support to fs.watch
Currently fs.watch does not have an option to specify if a directory
should be recursively watched for events across all subdirectories.
Several file watcher APIs support this. FSEvents on OS X > 10.5 is
one example. libuv has added support for FSEvents, but fs.watch had
no way to specify that a recursive watch was required.
fs.watch now has an additional boolean option 'recursive'. When set
to true, and when supported, fs.watch will return notifications for
the entire directory tree hierarchy rooted at the specified path.
Diffstat (limited to 'lib/fs.js')
-rw-r--r-- | lib/fs.js | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1014,9 +1014,11 @@ function FSWatcher() { } util.inherits(FSWatcher, EventEmitter); -FSWatcher.prototype.start = function(filename, persistent) { +FSWatcher.prototype.start = function(filename, persistent, recursive) { nullCheck(filename); - var err = this._handle.start(pathModule._makeLong(filename), persistent); + var err = this._handle.start(pathModule._makeLong(filename), + persistent, + recursive); if (err) { this._handle.close(); throw errnoException(err, 'watch'); @@ -1042,9 +1044,10 @@ fs.watch = function(filename) { } if (util.isUndefined(options.persistent)) options.persistent = true; + if (util.isUndefined(options.recursive)) options.recursive = false; watcher = new FSWatcher(); - watcher.start(filename, options.persistent); + watcher.start(filename, options.persistent, options.recursive); if (listener) { watcher.addListener('change', listener); |