1'use strict'; 2 3const common = require('../common'); 4const fixtures = require('../common/fixtures'); 5const assert = require('assert'); 6const fs = require('fs'); 7const path = require('path'); 8 9const tmpdir = require('../common/tmpdir'); 10tmpdir.refresh(); 11 12fs.access(Buffer.from(tmpdir.path), common.mustCall(assert.ifError)); 13 14const buf = Buffer.from(path.join(tmpdir.path, 'a.txt')); 15fs.open(buf, 'w+', common.mustCall((err, fd) => { 16 assert.ifError(err); 17 assert(fd); 18 fs.close(fd, common.mustCall(assert.ifError)); 19})); 20 21assert.throws( 22 () => { 23 fs.accessSync(true); 24 }, 25 { 26 code: 'ERR_INVALID_ARG_TYPE', 27 name: 'TypeError', 28 message: 'The "path" argument must be of type string or an instance of ' + 29 'Buffer or URL. Received type boolean (true)' 30 } 31); 32 33const dir = Buffer.from(fixtures.fixturesDir); 34fs.readdir(dir, 'hex', common.mustCall((err, hexList) => { 35 assert.ifError(err); 36 fs.readdir(dir, common.mustCall((err, stringList) => { 37 assert.ifError(err); 38 stringList.forEach((val, idx) => { 39 const fromHexList = Buffer.from(hexList[idx], 'hex').toString(); 40 assert.strictEqual( 41 fromHexList, 42 val, 43 `expected ${val}, got ${fromHexList} by hex decoding ${hexList[idx]}` 44 ); 45 }); 46 })); 47})); 48