diff options
author | James M Snell <jasnell@gmail.com> | 2018-05-15 12:34:49 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-05-20 14:15:56 -0700 |
commit | 7f0f978affda555c5f7151f2d6abd212e753d4f1 (patch) | |
tree | 3f40904376635a00f0a15cd33186be09715e903c /lib/internal/fs/utils.js | |
parent | a14a0fa8dc401188f67d26a82daae9423c54b41f (diff) | |
download | android-node-v8-7f0f978affda555c5f7151f2d6abd212e753d4f1.tar.gz android-node-v8-7f0f978affda555c5f7151f2d6abd212e753d4f1.tar.bz2 android-node-v8-7f0f978affda555c5f7151f2d6abd212e753d4f1.zip |
fs: refactor fs module
PR-URL: https://github.com/nodejs/node/pull/20764
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/internal/fs/utils.js')
-rw-r--r-- | lib/internal/fs/utils.js | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 46b3a97f74..a8c64e2b04 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -1,7 +1,6 @@ 'use strict'; const { Buffer, kMaxLength } = require('buffer'); -const { Writable } = require('stream'); const { ERR_FS_INVALID_SYMLINK_TYPE, ERR_INVALID_ARG_TYPE, @@ -11,7 +10,6 @@ const { ERR_OUT_OF_RANGE } = require('internal/errors').codes; const { isUint8Array } = require('internal/util/types'); -const fs = require('fs'); const pathModule = require('path'); const util = require('util'); @@ -256,45 +254,6 @@ function stringToSymlinkType(type) { return flags; } -// Temporary hack for process.stdout and process.stderr when piped to files. -function SyncWriteStream(fd, options) { - Writable.call(this); - - options = options || {}; - - this.fd = fd; - this.readable = false; - this.autoClose = options.autoClose === undefined ? true : options.autoClose; - - this.on('end', () => this._destroy()); -} - -util.inherits(SyncWriteStream, Writable); - -SyncWriteStream.prototype._write = function(chunk, encoding, cb) { - fs.writeSync(this.fd, chunk, 0, chunk.length); - cb(); - return true; -}; - -SyncWriteStream.prototype._destroy = function() { - if (this.fd === null) // already destroy()ed - return; - - if (this.autoClose) - fs.closeSync(this.fd); - - this.fd = null; - return true; -}; - -SyncWriteStream.prototype.destroySoon = -SyncWriteStream.prototype.destroy = function() { - this._destroy(); - this.emit('close'); - return true; -}; - // converts Date or number to a fractional UNIX timestamp function toUnixTimestamp(time, name = 'time') { // eslint-disable-next-line eqeqeq @@ -383,7 +342,6 @@ module.exports = { stringToFlags, stringToSymlinkType, Stats, - SyncWriteStream, toUnixTimestamp, validateBuffer, validateOffsetLengthRead, |