Permalink
Browse files

added chmod, fchmod, lchmod, chown, fchown, lchown

  • Loading branch information...
1 parent dcca394 commit de44ceb60aa0fab5be4c9d27b12d919288ebecff @tommy351 committed Sep 3, 2012
Showing with 29 additions and 16 deletions.
  1. +29 −16 lib/qfs.js
View
@@ -438,22 +438,6 @@ utils.each({
function(data){
}
- ],
- chmod: [
- function(mode, callback){
-
- },
- function(mode){
-
- }
- ],
- chown: [
- function(uid, gid, callback){
-
- },
- function(uid, gid){
-
- }
]
}, function(value, key){
qfs.fn[key] = function(){
@@ -468,4 +452,33 @@ utils.each({
return value[1].apply(this, args);
}
};
+});
+
+utils.each(['chmod', 'fchmod', 'lchmod', 'chown', 'fchown', 'lchown'], function(item){
+ qfs.fn[item] = function(){
+ var args = utils.toArray(arguments),
+ callback = args[args.length - 1];
+
+ // async
+ if (utils.isFunction(callback)){
+ var fn = [];
+
+ this.each(function(){
+ var path = this.path();
+
+ fn.push(function(next){
+ fs[item].apply(null, args.unshift(path));
+ });
+ });
+
+ async.parallel(fn, callback);
+ // sync
+ } else {
+ this.each(function(){
+ fs[item + 'Sync'].apply(null, args.unshift(this.path()));
+ });
+ }
+
+ return this;
+ };
});

0 comments on commit de44ceb

Please sign in to comment.