-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
60 lines (54 loc) · 1.31 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var Fs = require('fs');
var fAsync = require('./lib/async');
var fSync = require('./lib/sync');
var syncFunc = {};
/**
* extends function from Fs, exclude override
*/
for (var i in Fs) {
if (Fs.hasOwnProperty(i)) {
exports[i] = Fs[i];
if (i.indexOf('Sync') !== -1) {
syncFunc[i] = Fs[i];
}
}
}
syncFunc.save = fSync.writeFile;
syncFunc.mkdir = fSync.mkdir;
syncFunc.rmdir = fSync.rm;
syncFunc.rm = fSync.rm;
/**
* rmdir 递归删除目录,异步回调
* 支持dir / file删除, 如果文件不存在,则默认删除成功
* @param path file path
* @param callback
*/
exports.rmdir = fAsync.rm;
exports.rm = fAsync.rm;
/**
* mkdir 递归的创建目录,异步回调
* 如果文件目录存在,则默认返回成功
* @param path
* @param callback
*/
exports.mkdir = fAsync.mkdir;
/**
* rename 移动文件,异步回调,支持跨device移动
* @param {path} src
* @param {path} dest
* @param {function} cb
**/
exports.rename = fAsync.mv;
exports.mv = fAsync.mv;
/**
* save 保存到文件,如果目录不存在自动创建
* @param {path} path
* @param {String|Buffer} data
* @param {Function} cb(err);
*/
exports.save = fAsync.writeFile;
exports.writeFile = fAsync.writeFile;
exports.walk = fAsync.walk;
exports.sync = function () {
return syncFunc;
};