mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(commander) readDir
This commit is contained in:
parent
3e1dc7c582
commit
901f63a866
1 changed files with 8 additions and 10 deletions
|
|
@ -40,7 +40,7 @@
|
|||
* @param pFiles
|
||||
*/
|
||||
function readDir(params, error, files) {
|
||||
var i, n, stats, filesData, fill, name, fileParams,
|
||||
var n, stats, filesData, fill, fileParams,
|
||||
p = params,
|
||||
dirPath = format.addSlashToEnd(p.path);
|
||||
|
||||
|
|
@ -60,21 +60,19 @@
|
|||
|
||||
fill = fillJSON.bind(null, filesData);
|
||||
|
||||
if (n)
|
||||
for (i = 0; i < n; i++) {
|
||||
name = dirPath + files[i],
|
||||
|
||||
if (!n)
|
||||
fillJSON(filesData);
|
||||
else
|
||||
files.forEach(function(name) {
|
||||
fileParams = {
|
||||
callback : fill,
|
||||
count : n,
|
||||
name : files[i],
|
||||
name : name,
|
||||
stats : stats,
|
||||
};
|
||||
|
||||
fs.lstat(name, onStat.bind(null, fileParams));
|
||||
}
|
||||
else
|
||||
fillJSON(filesData);
|
||||
fs.lstat(dirPath + name, onStat.bind(null, fileParams));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue