README
enfscopy
Module that add copy functionality to node fs module
enfs stands for [E]asy [N]ode [fs]
This module is intended to work as a sub-module of enfs
Description
This module will add a method that allows the copy of multiple files and folder in the file system, similar to cp -R
- This module will add following methods to node fs module:
- copy
- copySync
Usage
enfscopy
var enfscopy = require("enfscopy");
Errors
All the methods follows the node culture.
- Async: Every async method returns an Error in the first callback parameter
- Sync: Every sync method throws an Error.
Additional Methods
copy
- copy(srcPath, dstPath, [options], callback)
Asynchronously copy items in the file system
[options]:
- fs (Object): an alternative fs module to use (default will be enfspatch)
- limit (Integer): the limit number of files being copied at a moment (Default: fs module limit or 512)
- overwrite (Boolean): if true will overwrite destination files if they exist before copy (Default: false)
- preserveTimestamps (Boolean): if true will preserve the timestamps of copied items (Default: false)
- stopOnError (Boolean): if true will stop copy execution at first error (Default: false)
- dereference (Boolean): if true will dereference symlinks copying the items to where it points (default: false)
- errors (Array or Stream): If array or stream, the errors that occur will be logged and returned
enfscopy.copy("/path/to/src/folder", "/path/to/destination", function(err, statistics){
if(!err){
console.log("Copied %d items with a total size of %d",statistics.items,statistics.size);
}
});
copySync
- copySync(srcPath, dstPath, [options])
Synchronously copy items in the file system
[options]:
- fs (Object): an alternative fs module to use (default will be enfspatch)
- limit (Integer): the limit number of files being copied at a moment (Default: fs module limit or 512)
- overwrite (Boolean): if true will overwrite destination files if they exist before copy (Default: false)
- preserveTimestamps (Boolean): if true will preserve the timestamps of copied items (Default: false)
- stopOnError (Boolean): if true will stop copy execution at first error (Default: false)
- dereference (Boolean): if true will dereference symlinks copying the items to where it points (default: false)
- errors (Array or Stream): If array or stream, the errors that occur will be logged and returned
var statistics = enfscopy.copySync("/path/to/src/folder", "/path/to/destination");
console.log("Copied %d items with a total size of %d",statistics.items,statistics.size);
Credit
This functionality is based on NCP with many improvements and a sync version.
License
Creative Commons Attribution 4.0 International License
Copyright (c) 2016 Joao Parreira joaofrparreira@gmail.com GitHub
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit CC-BY-4.0.