0.3.1 • Published 11 years ago

zfse v0.3.1

Weekly downloads
3
License
MIT
Repository
github
Last release
11 years ago

#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 : String

    The source directory.

  • dst : String

    The destination directory.

  • options : Object

    Options.

If the destination is a directory, the source file copy will be copied to it with the same file name.

#####Arguments

  • src : String

    The source file.

  • dst : String

    The destination file, or directory.

  • options : Object

    Options.

This method is a synchronous function, though it calls a callback function.

#####Arguments

  • dir : String

    The directory from which search starts.

  • namePattern : RegExp

    Search pattern in regular expression.

    If namePattern isn'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 to callback

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

This method works in a similar way as the following linux shell command:

find -name namePattern -exec mv \{\} newName \;

#####Arguments

  • dir : String

    The directory from which search starts.

  • namePattern : RegExp

    Search pattern in regular expression.

  • newName : String

    The new file name.

  • options : Object

    Options.

This method is a synchronous function, though it calls a callback function.

#####Arguments

  • dir : String

    The directory from which search starts.

  • options : Object

    Options.

    • options.depthfirst=true : Boolean

      If 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 : Boolean

      If true, when meeting a file node, calling to `callback` is delayed until returning back from all its sub-nodes.
  • callback : Function

    The callback function to run for each file node.

  • callback_arg...

    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);
});
0.3.1

11 years ago

0.3.0

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago