11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst fs = require('fs');
51cb0ef41Sopenharmony_ciconst assert = require('assert');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
81cb0ef41Sopenharmony_citmpdir.refresh();
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci{
111cb0ef41Sopenharmony_ci  // Compat error.
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci  function ReadStream(...args) {
141cb0ef41Sopenharmony_ci    fs.ReadStream.call(this, ...args);
151cb0ef41Sopenharmony_ci  }
161cb0ef41Sopenharmony_ci  Object.setPrototypeOf(ReadStream.prototype, fs.ReadStream.prototype);
171cb0ef41Sopenharmony_ci  Object.setPrototypeOf(ReadStream, fs.ReadStream);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  ReadStream.prototype.open = common.mustCall(function ReadStream$open() {
201cb0ef41Sopenharmony_ci    const that = this;
211cb0ef41Sopenharmony_ci    fs.open(that.path, that.flags, that.mode, (err, fd) => {
221cb0ef41Sopenharmony_ci      that.emit('error', err);
231cb0ef41Sopenharmony_ci    });
241cb0ef41Sopenharmony_ci  });
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci  const r = new ReadStream('/doesnotexist', { emitClose: true })
271cb0ef41Sopenharmony_ci    .on('error', common.mustCall((err) => {
281cb0ef41Sopenharmony_ci      assert.strictEqual(err.code, 'ENOENT');
291cb0ef41Sopenharmony_ci      assert.strictEqual(r.destroyed, true);
301cb0ef41Sopenharmony_ci      r.on('close', common.mustCall());
311cb0ef41Sopenharmony_ci    }));
321cb0ef41Sopenharmony_ci}
33