fs-enhance
v1.0.3
Published
extend file system apis for some more complex operation
Downloads
8
Maintainers
Readme
fs-enhance
extend file system apis for some more complex operation, more info
###Installation
npm install -g fs-enhance
###API
####fsEnhance.copyFile copy file
######parameter:
src
:String
source file pathtarget
:String
target file pathcb
:Function
the callback for error occur
######example:
var fsEnhance = require('fs-enhance');
fsEnhance.copyFile('aaa.js', 'bbb.js', function(err) {
if (err){
throw new Error('Error: copy file aaa.js error');
}
});
####fsEnhance.mkdir create folders in folder path, is similar to mkdir -p aaa/bbb/ccc
######parameter:
dirpath
:String
source folder pathmode
:String|Number
folder's file mode, mode defaults to 0777
######example:
var fsEnhance = require('fs-enhance');
fsEnhance.mkdir('aaa/bbb/ccc');
####fsEnhance.readDir traversal folder then excute the callback
######parameter:
src
:String
source file pathcb
:Function
the callback for each file or folder
//cb's arguments
{
path: filePath, //file's real path
type: 1|0 //file's type 1: file 0: folder
}
######example:
var fsEnhance = require('fs-enhance');
fsEnhance.readDir('./test', function(fileInfo){
console.log(fileInfo.path);
if (fileInfo.type === 1) {
//file ...
} else if (fileInfo.type === 0) {
//folder ...
}
});