1.0.3 • Published 11 years ago
fs-enhance v1.0.3
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:Stringsource file pathtarget:Stringtarget file pathcb:Functionthe 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:Stringsource folder pathmode:String|Numberfolder'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:Stringsource file pathcb:Functionthe 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 ...
}
});