mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-18 09:24:55 +00:00
数据列分开, 显示数据大小
This commit is contained in:
25
node_modules/common.js
generated
vendored
25
node_modules/common.js
generated
vendored
@@ -291,5 +291,30 @@ var Common = {
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 得到目录下的文件大小
|
||||
* @param {string} path 路径
|
||||
* @param {boolean} isRecursive 是否递归子目录
|
||||
* @return {number} 大小, 以KB为单位
|
||||
*/
|
||||
getFolderSize: function (path, isRecursive) {
|
||||
var me = this;
|
||||
var size = 0;
|
||||
var fies;
|
||||
if ( fs.existsSync(path) ) {
|
||||
files = fs.readdirSync(path);
|
||||
files.forEach(function(file, index) {
|
||||
var curPath = path + '/' + file;
|
||||
var stat = fs.statSync(curPath);
|
||||
if(stat.isDirectory() && isRecursive) {
|
||||
size += me.getFolderSize(curPath, isRecursive);
|
||||
} else {
|
||||
size += stat.size / 1000;
|
||||
}
|
||||
});
|
||||
}
|
||||
return size;
|
||||
}
|
||||
};
|
||||
module.exports = Common;
|
||||
|
Reference in New Issue
Block a user