Add fs.traverseTree

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-05-08 17:45:29 -07:00
parent d9d78ada51
commit 289193787e
2 changed files with 35 additions and 3 deletions

View File

@@ -80,6 +80,15 @@ module.exports =
makeDirectory: (path) ->
$native.makeDirectory(path)
traverseTree: (rootPath, fn) ->
recurse = null
prune = -> recurse = false
for path in @list(rootPath)
recurse = true
fn(path, prune)
@traverseTree(path, fn) if @isDirectory(path) and recurse
async:
list: (path) ->
deferred = $.Deferred()
@@ -91,5 +100,4 @@ module.exports =
deferred = $.Deferred()
$native.asyncList path, true, (subpaths) ->
deferred.resolve subpaths
deferred
deferred