zfse v0.3.1
#zfse
Zhou's File System Extension to the 'fs' module of node.js
##Installation $ npm install zfse
##Usage
var zfse = require('zfse');##API
###Methods
Method | Brief
:---------------------------|:-----
copyDir |Copies a directory.
copyFile |Copies a file.
find |Searches a directory.
rRmDir |Recursively removes a directory.
rRename |Recursively renames the files under a directory.
traverse |Traverses a directory with a specified callback applied to every file node.
#####Arguments
src: StringThe source directory.
dst: StringThe destination directory.
options: ObjectOptions.
If the destination is a directory, the source file copy will be copied to it with the same file name.
#####Arguments
src: StringThe source file.
dst: StringThe destination file, or directory.
options: ObjectOptions.
This method is a synchronous function, though it calls a callback function.
#####Arguments
dir: StringThe directory from which search starts.
namePattern: RegExpSearch pattern in regular expression.
If
namePatternisn't specified, all files (including sub-directories) will be matched.callback: Function The callback function to run for each file node that is found.callback_arg... Optional arguments passed tocallback
This method works in a similar way as linux shell command 'rm -rf'. If dir is a single file, this method works in the same way as fs.unlinkSync()
#####Arguments
dir: StringThe directory to remove.
options: ObjectOptions.
options.dryrun=false: BooleanDry-runs with verbose output only.
This method works in a similar way as the following linux shell command:
find -name namePattern -exec mv \{\} newName \;
#####Arguments
dir: StringThe directory from which search starts.
namePattern: RegExpSearch pattern in regular expression.
newName: StringThe new file name.
options: ObjectOptions.
options.dryrun=false: BooleanDry-runs with verbose output only.
This method is a synchronous function, though it calls a callback function.
#####Arguments
dir: StringThe directory from which search starts.
options: ObjectOptions.
options.depthfirst=true: BooleanIf true, [depth-first traversal](http://en.wikipedia.org/wiki/Depth-first_search); otherwise, [breadth-first traversal](http://en.wikipedia.org/wiki/Breadth-first_search)options.callbackdelay=true: BooleanIf true, when meeting a file node, calling to `callback` is delayed until returning back from all its sub-nodes.
callback: FunctionThe callback function to run for each file node.
Optional arguments passed to
callback.
#####Examples The following code snippet traverses through your current directory and prints every file node.
var zfse = require('zfse');
zfse.traverse('./', function (f) {
console.log(f);
});