|
@ -108,17 +108,16 @@ proto._maybeDispatch = function () { |
|
|
debugObject(self.currentAction); |
|
|
debugObject(self.currentAction); |
|
|
|
|
|
|
|
|
args = self.currentAction.args || []; |
|
|
args = self.currentAction.args || []; |
|
|
|
|
|
method = self.currentAction.method; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self.currentAction.method !== "open") { |
|
|
if (method !== "open") { |
|
|
args.unshift(self.fd); |
|
|
args.unshift(self.fd); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
method = self.currentAction.method; |
|
|
|
|
|
|
|
|
|
|
|
if (!args[3] && (method === "read" || method === "write")) { |
|
|
if (!args[3] && (method === "read" || method === "write")) { |
|
|
args[3] = self.encoding; |
|
|
args[3] = self.encoding; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
promise = node.fs[method].apply(self, args); |
|
|
promise = node.fs[method].apply(self, args); |
|
|
|
|
|
|
|
|
userPromise = self.currentAction.promise; |
|
|
userPromise = self.currentAction.promise; |
|
@ -144,21 +143,10 @@ proto._queueAction = function (method, args) { |
|
|
return userPromise; |
|
|
return userPromise; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// FIXME the following can probably be DRY'd up with some fancy getter
|
|
|
|
|
|
// stuff.
|
|
|
|
|
|
|
|
|
|
|
|
proto.open = function (filename, flags, mode) { |
|
|
(["open", "write", "read", "close"]).forEach(function (name) { |
|
|
return this._queueAction("open", [filename, flags, mode]); |
|
|
proto[name] = function () { |
|
|
}; |
|
|
return this._queueAction(name, Array.prototype.slice.call(arguments, 0)); |
|
|
|
|
|
|
|
|
proto.write = function (data, pos, encoding) { |
|
|
|
|
|
return this._queueAction("write", [data, pos, encoding]); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
proto.read = function (length, pos, encoding) { |
|
|
|
|
|
return this._queueAction("read", [length, pos, encoding]); |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
proto.close = function () { |
|
|
|
|
|
return this._queueAction("close"); |
|
|
|
|
|
}; |
|
|
|
|
|