|
|
@ -474,10 +474,10 @@ fs.realpath = function (path, callback) { |
|
|
|
} |
|
|
|
|
|
|
|
fs.createReadStream = function(path, options) { |
|
|
|
return new FileReadStream(path, options); |
|
|
|
return new ReadStream(path, options); |
|
|
|
}; |
|
|
|
|
|
|
|
var FileReadStream = fs.FileReadStream = function(path, options) { |
|
|
|
var ReadStream = fs.ReadStream = function(path, options) { |
|
|
|
events.EventEmitter.call(this); |
|
|
|
|
|
|
|
this.path = path; |
|
|
@ -516,13 +516,15 @@ var FileReadStream = fs.FileReadStream = function(path, options) { |
|
|
|
self._read(); |
|
|
|
}); |
|
|
|
}; |
|
|
|
sys.inherits(FileReadStream, events.EventEmitter); |
|
|
|
sys.inherits(ReadStream, events.EventEmitter); |
|
|
|
|
|
|
|
FileReadStream.prototype.setEncoding = function(encoding) { |
|
|
|
fs.FileReadStream = fs.ReadStream; // support the legacy name
|
|
|
|
|
|
|
|
ReadStream.prototype.setEncoding = function(encoding) { |
|
|
|
this.encoding = encoding; |
|
|
|
}; |
|
|
|
|
|
|
|
FileReadStream.prototype._read = function () { |
|
|
|
ReadStream.prototype._read = function () { |
|
|
|
var self = this; |
|
|
|
if (!self.readable || self.paused) return; |
|
|
|
|
|
|
@ -562,16 +564,16 @@ FileReadStream.prototype._read = function () { |
|
|
|
|
|
|
|
var readStreamForceCloseWarning; |
|
|
|
|
|
|
|
FileReadStream.prototype.forceClose = function (cb) { |
|
|
|
ReadStream.prototype.forceClose = function (cb) { |
|
|
|
if (!readStreamForceCloseWarning) { |
|
|
|
readStreamForceCloseWarning = "FileReadStream.prototype.forceClose renamed to destroy()"; |
|
|
|
readStreamForceCloseWarning = "ReadStream.prototype.forceClose renamed to destroy()"; |
|
|
|
sys.error(readStreamForceCloseWarning); |
|
|
|
} |
|
|
|
return this.destroy(cb); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileReadStream.prototype.destroy = function (cb) { |
|
|
|
ReadStream.prototype.destroy = function (cb) { |
|
|
|
var self = this; |
|
|
|
this.readable = false; |
|
|
|
|
|
|
@ -600,12 +602,12 @@ FileReadStream.prototype.destroy = function (cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
FileReadStream.prototype.pause = function() { |
|
|
|
ReadStream.prototype.pause = function() { |
|
|
|
this.paused = true; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
FileReadStream.prototype.resume = function() { |
|
|
|
ReadStream.prototype.resume = function() { |
|
|
|
this.paused = false; |
|
|
|
|
|
|
|
if (this.buffer) { |
|
|
@ -619,10 +621,10 @@ FileReadStream.prototype.resume = function() { |
|
|
|
|
|
|
|
|
|
|
|
fs.createWriteStream = function(path, options) { |
|
|
|
return new FileWriteStream(path, options); |
|
|
|
return new WriteStream(path, options); |
|
|
|
}; |
|
|
|
|
|
|
|
var FileWriteStream = fs.FileWriteStream = function(path, options) { |
|
|
|
var WriteStream = fs.WriteStream = function(path, options) { |
|
|
|
events.EventEmitter.call(this); |
|
|
|
|
|
|
|
this.path = path; |
|
|
@ -650,11 +652,12 @@ var FileWriteStream = fs.FileWriteStream = function(path, options) { |
|
|
|
this.flush(); |
|
|
|
} |
|
|
|
}; |
|
|
|
sys.inherits(FileWriteStream, events.EventEmitter); |
|
|
|
sys.inherits(WriteStream, events.EventEmitter); |
|
|
|
|
|
|
|
fs.FileWriteStream = fs.WriteStream; // support the legacy name
|
|
|
|
|
|
|
|
|
|
|
|
FileWriteStream.prototype.flush = function () { |
|
|
|
WriteStream.prototype.flush = function () { |
|
|
|
if (this.busy) return; |
|
|
|
var self = this; |
|
|
|
|
|
|
@ -710,7 +713,7 @@ FileWriteStream.prototype.flush = function () { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
FileWriteStream.prototype.write = function(data, encoding) { |
|
|
|
WriteStream.prototype.write = function(data, encoding) { |
|
|
|
if (!this.writeable) { |
|
|
|
throw new Error('stream not writeable'); |
|
|
|
} |
|
|
@ -726,16 +729,16 @@ FileWriteStream.prototype.write = function(data, encoding) { |
|
|
|
|
|
|
|
var writeStreamCloseWarning; |
|
|
|
|
|
|
|
FileWriteStream.prototype.close = function (cb) { |
|
|
|
WriteStream.prototype.close = function (cb) { |
|
|
|
if (!writeStreamCloseWarning) { |
|
|
|
writeStreamCloseWarning = "FileWriteStream.prototype.close renamed to end()"; |
|
|
|
writeStreamCloseWarning = "WriteStream.prototype.close renamed to end()"; |
|
|
|
sys.error(writeStreamCloseWarning); |
|
|
|
} |
|
|
|
return this.end(cb); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileWriteStream.prototype.end = function (cb) { |
|
|
|
WriteStream.prototype.end = function (cb) { |
|
|
|
this.writeable = false; |
|
|
|
this._queue.push([fs.close, cb]); |
|
|
|
this.flush(); |
|
|
@ -744,16 +747,16 @@ FileWriteStream.prototype.end = function (cb) { |
|
|
|
|
|
|
|
var writeStreamForceCloseWarning; |
|
|
|
|
|
|
|
FileWriteStream.prototype.forceClose = function (cb) { |
|
|
|
WriteStream.prototype.forceClose = function (cb) { |
|
|
|
if (!writeStreamForceCloseWarning) { |
|
|
|
writeStreamForceCloseWarning = "FileWriteStream.prototype.forceClose renamed to destroy()"; |
|
|
|
writeStreamForceCloseWarning = "WriteStream.prototype.forceClose renamed to destroy()"; |
|
|
|
sys.error(writeStreamForceCloseWarning); |
|
|
|
} |
|
|
|
return this.destroy(cb); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileWriteStream.prototype.forceClose = function (cb) { |
|
|
|
WriteStream.prototype.forceClose = function (cb) { |
|
|
|
this.writeable = false; |
|
|
|
fs.close(self.fd, function(err) { |
|
|
|
if (err) { |
|
|
|