- `stats.isSocket()`
-## fs.FileReadStream
+## fs.ReadStream
-`FileReadStream` is a readable stream.
+`ReadStream` is a readable stream.
### fs.createReadStream(path, [options])
-Returns a new FileReadStream object.
+Returns a new ReadStream object.
`options` is an object with the following defaults:
Allows to close the stream before the `'end'` is reached. No more events other
than `'close'` will be fired after this method has been called.
-## fs.FileWriteStream
+## fs.WriteStream
-`FileWriteStream` is a writable stream.
+`WriteStream` is a writable stream.
### fs.createWriteStream(path, [options])
-Returns a new FileWriteStream object.
+Returns a new WriteStream object.
`options` is an object with the following defaults:
{ 'flags': 'w'
}
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;
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;
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;
};
-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) {
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;
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;
};
-FileWriteStream.prototype.write = function(data, encoding) {
+WriteStream.prototype.write = function(data, encoding) {
if (!this.writeable) {
throw new Error('stream not writeable');
}
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();
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) {