commit
49e9260caa
|
@ -33,6 +33,8 @@ The Synchronous version still uses callbacks, so it is safe to use with other As
|
|||
|
||||
options = {
|
||||
followLinks: false,
|
||||
// filters: ["Temp", "_Temp"] // directories with these
|
||||
// keys will be skipped
|
||||
};
|
||||
|
||||
walker = walk.walk("/tmp", options);
|
||||
|
|
24
lib/walk.js
24
lib/walk.js
|
@ -35,6 +35,7 @@
|
|||
me._wq = [];
|
||||
me._wqueue = [me._wq];
|
||||
me._wcurpath = undefined;
|
||||
me._wfilters = options.filters;
|
||||
me._wfirstrun = true;
|
||||
me._wcurpath = pathname;
|
||||
|
||||
|
@ -175,11 +176,24 @@
|
|||
, me = this
|
||||
;
|
||||
|
||||
// Stop directories that contain filter keywords
|
||||
// from continuing through the walk process
|
||||
if (me._wfilters != undefined) {
|
||||
var shouldExclude = false;
|
||||
for (var iFilter=0; iFilter<me._wfilters.length; ++iFilter) {
|
||||
if (me._wcurpath.indexOf(me._wfilters[iFilter]) != -1 ) {
|
||||
me._wNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !shouldExclude ) {
|
||||
try {
|
||||
files = fs.readdirSync(me._wcurpath);
|
||||
} catch(e) {
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
|
||||
me._wReaddirHandler(err, files);
|
||||
};
|
||||
|
@ -187,6 +201,16 @@
|
|||
var me = this
|
||||
;
|
||||
|
||||
// Stop directories that contain filter keywords
|
||||
// from continuing through the walk process
|
||||
if (me._wfilters != undefined) {
|
||||
for (var iFilter=0; iFilter<me._wfilters.length; ++iFilter) {
|
||||
if (me._wcurpath.indexOf(me._wfilters[iFilter]) != -1 ) {
|
||||
me._wNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO how to remove this anony?
|
||||
fs.readdir(me._wcurpath, function (err, files) {
|
||||
me._wReaddirHandler(err, files);
|
||||
|
|
Loading…
Reference in New Issue