untio-hua-copy
v1.0.1
Published
```javascript function del(fileSrc) { fs.readdirSync(fileSrc).forEach(item => { item = fileSrc + '/' + item; console.log(item); if (fs.statSync(item).isFile()) { fs.unlinkSync(item); } else {
Downloads
2
Readme
#fs算法
##删除文件夹
function del(fileSrc) {
fs.readdirSync(fileSrc).forEach(item => {
item = fileSrc + '/' + item;
console.log(item);
if (fs.statSync(item).isFile()) {
fs.unlinkSync(item);
} else {
del(item);
}
})
}
##复制文件
function copydir(dir, newdir) {
!fs.existsSync(newdir) && fs.mkdirSync(newdir);
fs.readdirSync(dir).forEach(item => {
let dirname = dir + '/' + item;
let newdirName = newdir + '/' + item;
if (fs.statSync(dirname).isFile()) {
let read = fs.createReadStream(dirname);
} else {
copydir(dirname, newdirName);
}
})
}