mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-24 08:29:53 +00:00
feature(files) add readPipe
This commit is contained in:
parent
1ad1e7e14c
commit
b621a05832
1 changed files with 27 additions and 0 deletions
|
|
@ -12,6 +12,7 @@
|
|||
var main = global.cloudcmd.main,
|
||||
fs = main.fs,
|
||||
path = main.path,
|
||||
pipe = main.pipe,
|
||||
CloudFunc = main.cloudfunc,
|
||||
Util = main.util;
|
||||
|
||||
|
|
@ -67,4 +68,30 @@
|
|||
}
|
||||
};
|
||||
|
||||
object.readPipe = readPipe;
|
||||
|
||||
function readPipe(files, writeStream, callback) {
|
||||
var name, length = files && files.length;
|
||||
|
||||
if (!length)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
name = files.pop();
|
||||
|
||||
pipe.create({
|
||||
from : name,
|
||||
write : writeStream,
|
||||
callback: function(error) {
|
||||
if (error)
|
||||
Util.exec(callback, error);
|
||||
else
|
||||
if (!length)
|
||||
Util.exec(callback);
|
||||
else
|
||||
readPipe(files, writeStream, callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
})(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue