{"version":3,"file":"binding.mjs","names":[],"sources":["../../../../../node_modules/mock-fs/lib/binding.js"],"sourcesContent":["'use strict';\n\nconst path = require('path');\nconst File = require('./file.js');\nconst FileDescriptor = require('./descriptor.js');\nconst Directory = require('./directory.js');\nconst SymbolicLink = require('./symlink.js');\nconst {FSError} = require('./error.js');\nconst constants = require('constants');\nconst {getPathParts, getRealPath} = require('./filesystem.js');\n\nconst MODE_TO_KTYPE = {\n  [constants.S_IFREG]: constants.UV_DIRENT_FILE,\n  [constants.S_IFDIR]: constants.UV_DIRENT_DIR,\n  [constants.S_IFBLK]: constants.UV_DIRENT_BLOCK,\n  [constants.S_IFCHR]: constants.UV_DIRENT_CHAR,\n  [constants.S_IFLNK]: constants.UV_DIRENT_LINK,\n  [constants.S_IFIFO]: constants.UV_DIRENT_FIFO,\n  [constants.S_IFSOCK]: constants.UV_DIRENT_SOCKET,\n};\n\n/** Workaround for optimizations in node 8+ */\nconst fsBinding = process.binding('fs');\nconst kUsePromises = fsBinding.kUsePromises;\nlet statValues;\nlet bigintStatValues;\nif (fsBinding.statValues) {\n  statValues = fsBinding.statValues; // node 10+\n  bigintStatValues = fsBinding.bigintStatValues;\n}\n\nconst MAX_LINKS = 50;\n\n/**\n * Call the provided function and either return the result or call the callback\n * with it (depending on if a callback is provided).\n * @param {function()} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @param {object} thisArg This argument for the following function.\n * @param {function()} func Function to call.\n * @return {*} Return (if callback is not provided).\n */\nfunction maybeCallback(callback, ctx, thisArg, func) {\n  let err = null;\n  let val;\n\n  if (usePromises(callback)) {\n    // support nodejs v10+ fs.promises\n    try {\n      val = func.call(thisArg);\n    } catch (e) {\n      err = e;\n    }\n    return new Promise(function (resolve, reject) {\n      process.nextTick(function () {\n        if (err) {\n          reject(err);\n        } else {\n          resolve(val);\n        }\n      });\n    });\n  } else if (callback && typeof callback === 'function') {\n    try {\n      val = func.call(thisArg);\n    } catch (e) {\n      err = e;\n    }\n    process.nextTick(function () {\n      if (val === undefined) {\n        callback(err);\n      } else {\n        callback(err, val);\n      }\n    });\n  } else if (ctx && typeof ctx === 'object') {\n    try {\n      return func.call(thisArg);\n    } catch (e) {\n      // default to errno for UNKNOWN\n      ctx.code = e.code || 'UNKNOWN';\n      ctx.errno = e.errno || FSError.codes.UNKNOWN.errno;\n    }\n  } else {\n    return func.call(thisArg);\n  }\n}\n\nfunction usePromises(callback) {\n  return kUsePromises && callback === kUsePromises;\n}\n\n/**\n * set syscall property on context object, only for nodejs v10+.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @param {string} syscall Name of syscall.\n */\nfunction markSyscall(ctx, syscall) {\n  if (ctx && typeof ctx === 'object') {\n    ctx.syscall = syscall;\n  }\n}\n\n/**\n * Handle FSReqWrap oncomplete.\n * @param {Function} callback The callback.\n * @return {Function} The normalized callback.\n */\nfunction normalizeCallback(callback) {\n  if (callback && typeof callback.oncomplete === 'function') {\n    // Unpack callback from FSReqWrap\n    callback = callback.oncomplete.bind(callback);\n  }\n  return callback;\n}\n\nfunction getDirentType(mode) {\n  const ktype = MODE_TO_KTYPE[mode & constants.S_IFMT];\n\n  if (ktype === undefined) {\n    return constants.UV_DIRENT_UNKNOWN;\n  }\n\n  return ktype;\n}\n\nfunction notImplemented() {\n  throw new Error('Method not implemented');\n}\n\nfunction deBuffer(p) {\n  return Buffer.isBuffer(p) ? p.toString() : p;\n}\n\n/**\n * Create a new binding with the given file system.\n * @param {FileSystem} system Mock file system.\n * @class\n */\nfunction Binding(system) {\n  /**\n   * Mock file system.\n   * @type {FileSystem}\n   */\n  this._system = system;\n\n  /**\n   * Lookup of open files.\n   * @type {Object<number, FileDescriptor>}\n   */\n  this._openFiles = {};\n\n  /**\n   * Counter for file descriptors.\n   * @type {number}\n   */\n  this._counter = -1;\n\n  const stdin = new FileDescriptor(constants.O_RDWR);\n  stdin.setItem(new File.StandardInput());\n  this.trackDescriptor(stdin);\n\n  const stdout = new FileDescriptor(constants.O_RDWR);\n  stdout.setItem(new File.StandardOutput());\n  this.trackDescriptor(stdout);\n\n  const stderr = new FileDescriptor(constants.O_RDWR);\n  stderr.setItem(new File.StandardError());\n  this.trackDescriptor(stderr);\n}\n\n/**\n * Get the file system underlying this binding.\n * @return {FileSystem} The underlying file system.\n */\nBinding.prototype.getSystem = function () {\n  return this._system;\n};\n\n/**\n * Reset the file system underlying this binding.\n * @param {FileSystem} system The new file system.\n */\nBinding.prototype.setSystem = function (system) {\n  this._system = system;\n};\n\n/**\n * Get a file descriptor.\n * @param {number} fd File descriptor identifier.\n * @return {FileDescriptor} File descriptor.\n */\nBinding.prototype.getDescriptorById = function (fd) {\n  if (!this._openFiles.hasOwnProperty(fd)) {\n    throw new FSError('EBADF');\n  }\n  return this._openFiles[fd];\n};\n\n/**\n * Keep track of a file descriptor as open.\n * @param {FileDescriptor} descriptor The file descriptor.\n * @return {number} Identifier for file descriptor.\n */\nBinding.prototype.trackDescriptor = function (descriptor) {\n  const fd = ++this._counter;\n  this._openFiles[fd] = descriptor;\n  return fd;\n};\n\n/**\n * Stop tracking a file descriptor as open.\n * @param {number} fd Identifier for file descriptor.\n */\nBinding.prototype.untrackDescriptorById = function (fd) {\n  if (!this._openFiles.hasOwnProperty(fd)) {\n    throw new FSError('EBADF');\n  }\n  delete this._openFiles[fd];\n};\n\n/**\n * Resolve the canonicalized absolute pathname.\n * @param {string|Buffer} filepath The file path.\n * @param {string} encoding The encoding for the return.\n * @param {Function} callback The callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {string|Buffer} The real path.\n */\nBinding.prototype.realpath = function (filepath, encoding, callback, ctx) {\n  markSyscall(ctx, 'realpath');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    let realPath;\n    filepath = deBuffer(filepath);\n    const resolved = path.resolve(filepath);\n    const parts = getPathParts(resolved);\n    let item = this._system.getRoot();\n    let itemPath = '/';\n    let name, i, ii;\n    for (i = 0, ii = parts.length; i < ii; ++i) {\n      name = parts[i];\n      while (item instanceof SymbolicLink) {\n        itemPath = path.resolve(path.dirname(itemPath), item.getPath());\n        item = this._system.getItem(itemPath);\n      }\n      if (!item) {\n        throw new FSError('ENOENT', filepath);\n      }\n      if (item instanceof Directory) {\n        itemPath = path.resolve(itemPath, name);\n        item = item.getItem(name);\n      } else {\n        throw new FSError('ENOTDIR', filepath);\n      }\n    }\n    if (item) {\n      while (item instanceof SymbolicLink) {\n        itemPath = path.resolve(path.dirname(itemPath), item.getPath());\n        item = this._system.getItem(itemPath);\n      }\n      realPath = itemPath;\n    } else {\n      throw new FSError('ENOENT', filepath);\n    }\n\n    // Remove win32 file namespace prefix \\\\?\\\n    realPath = getRealPath(realPath);\n\n    if (encoding === 'buffer') {\n      realPath = Buffer.from(realPath);\n    }\n\n    return realPath;\n  });\n};\n\nfunction fillStats(stats, bigint) {\n  const target = bigint ? bigintStatValues : statValues;\n  for (let i = 0; i < 36; i++) {\n    target[i] = stats[i];\n  }\n}\n\n/**\n * Stat an item.\n * @param {string} filepath Path.\n * @param {boolean} bigint Use BigInt.\n * @param {function(Error, Float64Array|BigUint64Array)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {Float64Array|BigUint64Array|undefined} Stats or undefined (if sync).\n */\nBinding.prototype.stat = function (filepath, bigint, callback, ctx) {\n  markSyscall(ctx, 'stat');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    filepath = deBuffer(filepath);\n    let item = this._system.getItem(filepath);\n    if (item instanceof SymbolicLink) {\n      item = this._system.getItem(\n        path.resolve(path.dirname(filepath), item.getPath())\n      );\n    }\n    if (!item) {\n      throw new FSError('ENOENT', filepath);\n    }\n    const stats = item.getStats(bigint);\n    fillStats(stats, bigint);\n    return stats;\n  });\n};\n\n/**\n * Stat an item.\n * @param {string} filepath Path.\n * @param {boolean} bigint Use BigInt.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {Float64Array|BigUint64Array|undefined} Stats or undefined if sync.\n */\nBinding.prototype.statSync = function (filepath, bigint, ctx) {\n  return this.stat(filepath, bigint, undefined, ctx);\n};\n\n/**\n * Stat an item.\n * @param {number} fd File descriptor.\n * @param {boolean} bigint Use BigInt.\n * @param {function(Error, Float64Array|BigUint64Array)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {Float64Array|BigUint64Array|undefined} Stats or undefined (if sync).\n */\nBinding.prototype.fstat = function (fd, bigint, callback, ctx) {\n  markSyscall(ctx, 'fstat');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    const item = descriptor.getItem();\n    const stats = item.getStats(bigint);\n    fillStats(stats, bigint);\n    return stats;\n  });\n};\n\n/**\n * Close a file descriptor.\n * @param {number} fd File descriptor.\n * @param {function(Error)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback.\n */\nBinding.prototype.close = function (fd, callback, ctx) {\n  markSyscall(ctx, 'close');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    this.untrackDescriptorById(fd);\n  });\n};\n\n/**\n * Close a file descriptor.\n * @param {number} fd File descriptor.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return.\n */\nBinding.prototype.closeSync = function (fd, ctx) {\n  return this.close(fd, undefined, ctx);\n};\n\n/**\n * Open and possibly create a file.\n * @param {string} pathname File path.\n * @param {number} flags Flags.\n * @param {number} mode Mode.\n * @param {function(Error, string)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {string} File descriptor (if sync).\n */\nBinding.prototype.open = function (pathname, flags, mode, callback, ctx) {\n  markSyscall(ctx, 'open');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const descriptor = new FileDescriptor(flags, usePromises(callback));\n    let item = this._system.getItem(pathname);\n    while (item instanceof SymbolicLink) {\n      item = this._system.getItem(\n        path.resolve(path.dirname(pathname), item.getPath())\n      );\n    }\n    if (descriptor.isExclusive() && item) {\n      throw new FSError('EEXIST', pathname);\n    }\n    if (descriptor.isCreate() && !item) {\n      const parent = this._system.getItem(path.dirname(pathname));\n      if (!parent) {\n        throw new FSError('ENOENT', pathname);\n      }\n      if (!(parent instanceof Directory)) {\n        throw new FSError('ENOTDIR', pathname);\n      }\n      item = new File();\n      if (mode) {\n        item.setMode(mode);\n      }\n      parent.addItem(path.basename(pathname), item);\n    }\n    if (descriptor.isRead()) {\n      if (!item) {\n        throw new FSError('ENOENT', pathname);\n      }\n      if (!item.canRead()) {\n        throw new FSError('EACCES', pathname);\n      }\n    }\n    if (descriptor.isWrite() && !item.canWrite()) {\n      throw new FSError('EACCES', pathname);\n    }\n    if (\n      item instanceof Directory &&\n      (descriptor.isTruncate() || descriptor.isAppend())\n    ) {\n      throw new FSError('EISDIR', pathname);\n    }\n    if (descriptor.isTruncate()) {\n      if (!(item instanceof File)) {\n        throw new FSError('EBADF');\n      }\n      item.setContent('');\n    }\n    if (descriptor.isTruncate() || descriptor.isAppend()) {\n      descriptor.setPosition(item.getContent().length);\n    }\n    descriptor.setItem(item);\n    return this.trackDescriptor(descriptor);\n  });\n};\n\n/**\n * Open and possibly create a file.\n * @param {string} pathname File path.\n * @param {number} flags Flags.\n * @param {number} mode Mode.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {string} File descriptor.\n */\nBinding.prototype.openSync = function (pathname, flags, mode, ctx) {\n  return this.open(pathname, flags, mode, undefined, ctx);\n};\n\n/**\n * Open a file handler. A new api in nodejs v10+ for fs.promises\n * @param {string} pathname File path.\n * @param {number} flags Flags.\n * @param {number} mode Mode.\n * @param {Function} callback Callback (optional), expecting kUsePromises in nodejs v10+.\n * @return {string} The file handle.\n */\nBinding.prototype.openFileHandle = function (pathname, flags, mode, callback) {\n  const self = this;\n\n  return this.open(pathname, flags, mode, kUsePromises).then(function (fd) {\n    // nodejs v10+ fs.promises FileHandler constructor only ask these three properties.\n    return {\n      getAsyncId: notImplemented,\n      fd: fd,\n      close: function () {\n        return self.close(fd, kUsePromises);\n      },\n    };\n  });\n};\n\n/**\n * Read from a file descriptor.\n * @param {string} fd File descriptor.\n * @param {Buffer} buffer Buffer that the contents will be written to.\n * @param {number} offset Offset in the buffer to start writing to.\n * @param {number} length Number of bytes to read.\n * @param {?number} position Where to begin reading in the file.  If null,\n *     data will be read from the current file position.\n * @param {function(Error, number, Buffer)} callback Callback (optional) called\n *     with any error, number of bytes read, and the buffer.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {number} Number of bytes read (if sync).\n */\nBinding.prototype.read = function (\n  fd,\n  buffer,\n  offset,\n  length,\n  position,\n  callback,\n  ctx\n) {\n  markSyscall(ctx, 'read');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    if (!descriptor.isRead()) {\n      throw new FSError('EBADF');\n    }\n    const file = descriptor.getItem();\n    if (file instanceof Directory) {\n      throw new FSError('EISDIR');\n    }\n    if (!(file instanceof File)) {\n      // deleted or not a regular file\n      throw new FSError('EBADF');\n    }\n    if (typeof position !== 'number' || position < 0) {\n      position = descriptor.getPosition();\n    }\n    const content = file.getContent();\n    const start = Math.min(position, content.length);\n    const end = Math.min(position + length, content.length);\n    const read = start < end ? content.copy(buffer, offset, start, end) : 0;\n    descriptor.setPosition(position + read);\n    return read;\n  });\n};\n\n/**\n * Write to a file descriptor given a buffer.\n * @param {string} src Source file.\n * @param {string} dest Destination file.\n * @param {number} flags Modifiers for copy operation.\n * @param {function(Error)} callback Callback (optional) called\n *     with any error.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.copyFile = function (src, dest, flags, callback, ctx) {\n  markSyscall(ctx, 'copyfile');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    src = deBuffer(src);\n    dest = deBuffer(dest);\n    const srcFd = this.open(src, constants.O_RDONLY);\n\n    try {\n      const srcDescriptor = this.getDescriptorById(srcFd);\n      if (!srcDescriptor.isRead()) {\n        throw new FSError('EBADF');\n      }\n      const srcFile = srcDescriptor.getItem();\n      if (!(srcFile instanceof File)) {\n        throw new FSError('EBADF');\n      }\n      const srcContent = srcFile.getContent();\n\n      let destFlags =\n        constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC;\n\n      if ((flags & constants.COPYFILE_EXCL) === constants.COPYFILE_EXCL) {\n        destFlags |= constants.O_EXCL;\n      }\n\n      const destFd = this.open(dest, destFlags);\n\n      try {\n        this.writeBuffer(destFd, srcContent, 0, srcContent.length, 0);\n      } finally {\n        this.close(destFd);\n      }\n    } finally {\n      this.close(srcFd);\n    }\n  });\n};\n\n/**\n * Write to a file descriptor given a buffer.\n * @param {string} src Source file.\n * @param {string} dest Destination file.\n * @param {number} flags Modifiers for copy operation.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.copyFileSync = function (src, dest, flags, ctx) {\n  return this.copyFile(src, dest, flags, undefined, ctx);\n};\n\n/**\n * Write to a file descriptor given a buffer.\n * @param {string} fd File descriptor.\n * @param {Array<Buffer>} buffers Array of buffers with contents to write.\n * @param {?number} position Where to begin writing in the file.  If null,\n *     data will be written to the current file position.\n * @param {function(Error, number, Buffer)} callback Callback (optional) called\n *     with any error, number of bytes written, and the buffer.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {number} Number of bytes written (if sync).\n */\nBinding.prototype.writeBuffers = function (\n  fd,\n  buffers,\n  position,\n  callback,\n  ctx\n) {\n  markSyscall(ctx, 'write');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    if (!descriptor.isWrite()) {\n      throw new FSError('EBADF');\n    }\n    const file = descriptor.getItem();\n    if (!(file instanceof File)) {\n      // not a regular file\n      throw new FSError('EBADF');\n    }\n    if (typeof position !== 'number' || position < 0) {\n      position = descriptor.getPosition();\n    }\n    let content = file.getContent();\n    const newContent = Buffer.concat(buffers);\n    const newLength = position + newContent.length;\n    if (content.length < newLength) {\n      const tempContent = Buffer.alloc(newLength);\n      content.copy(tempContent);\n      content = tempContent;\n    }\n    const written = newContent.copy(content, position);\n    file.setContent(content);\n    descriptor.setPosition(newLength);\n    return written;\n  });\n};\n\n/**\n * Write to a file descriptor given a buffer.\n * @param {string} fd File descriptor.\n * @param {Buffer} buffer Buffer with contents to write.\n * @param {number} offset Offset in the buffer to start writing from.\n * @param {number} length Number of bytes to write.\n * @param {?number} position Where to begin writing in the file.  If null,\n *     data will be written to the current file position.\n * @param {function(Error, number, Buffer)} callback Callback (optional) called\n *     with any error, number of bytes written, and the buffer.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {number} Number of bytes written (if sync).\n */\nBinding.prototype.writeBuffer = function (\n  fd,\n  buffer,\n  offset,\n  length,\n  position,\n  callback,\n  ctx\n) {\n  markSyscall(ctx, 'write');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    if (!descriptor.isWrite()) {\n      throw new FSError('EBADF');\n    }\n    const file = descriptor.getItem();\n    if (!(file instanceof File)) {\n      // not a regular file\n      throw new FSError('EBADF');\n    }\n    if (typeof position !== 'number' || position < 0) {\n      position = descriptor.getPosition();\n    }\n    let content = file.getContent();\n    const newLength = position + length;\n    if (content.length < newLength) {\n      const newContent = Buffer.alloc(newLength);\n      content.copy(newContent);\n      content = newContent;\n    }\n    const sourceEnd = Math.min(offset + length, buffer.length);\n    const written = Buffer.from(buffer).copy(\n      content,\n      position,\n      offset,\n      sourceEnd\n    );\n    file.setContent(content);\n    descriptor.setPosition(newLength);\n    // If we're in fs.promises / FileHandle we need to return a promise\n    // Both fs.promises.open().then(fd => fs.write())\n    // and fs.openSync().writeSync() use this function\n    // without a callback, so we have to check if  the descriptor was opened\n    // with kUsePromises\n    return descriptor.isPromise() ? Promise.resolve(written) : written;\n  });\n};\n\n/**\n * Write to a file descriptor given a string.\n * @param {string} fd File descriptor.\n * @param {string} string String with contents to write.\n * @param {number} position Where to begin writing in the file.  If null,\n *     data will be written to the current file position.\n * @param {string} encoding String encoding.\n * @param {function(Error, number, string)} callback Callback (optional) called\n *     with any error, number of bytes written, and the string.\n * @param {object} ctx The context.\n * @return {number} Number of bytes written (if sync).\n */\nBinding.prototype.writeString = function (\n  fd,\n  string,\n  position,\n  encoding,\n  callback,\n  ctx\n) {\n  markSyscall(ctx, 'write');\n\n  const buffer = Buffer.from(string, encoding);\n  let wrapper;\n  if (callback && callback !== kUsePromises) {\n    if (callback.oncomplete) {\n      callback = callback.oncomplete.bind(callback);\n    }\n    wrapper = function (err, written, returned) {\n      callback(err, written, returned && string);\n    };\n  }\n  return this.writeBuffer(fd, buffer, 0, string.length, position, wrapper, ctx);\n};\n\n/**\n * Rename a file.\n * @param {string} oldPath Old pathname.\n * @param {string} newPath New pathname.\n * @param {function(Error)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {undefined}\n */\nBinding.prototype.rename = function (oldPath, newPath, callback, ctx) {\n  markSyscall(ctx, 'rename');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    oldPath = deBuffer(oldPath);\n    newPath = deBuffer(newPath);\n    const oldItem = this._system.getItem(oldPath);\n    if (!oldItem) {\n      throw new FSError('ENOENT', oldPath);\n    }\n    const oldParent = this._system.getItem(path.dirname(oldPath));\n    const oldName = path.basename(oldPath);\n    const newItem = this._system.getItem(newPath);\n    const newParent = this._system.getItem(path.dirname(newPath));\n    const newName = path.basename(newPath);\n    if (newItem) {\n      // make sure they are the same type\n      if (oldItem instanceof File) {\n        if (newItem instanceof Directory) {\n          throw new FSError('EISDIR', newPath);\n        }\n      } else if (oldItem instanceof Directory) {\n        if (!(newItem instanceof Directory)) {\n          throw new FSError('ENOTDIR', newPath);\n        }\n        if (newItem.list().length > 0) {\n          throw new FSError('ENOTEMPTY', newPath);\n        }\n      }\n      newParent.removeItem(newName);\n    } else {\n      if (!newParent) {\n        throw new FSError('ENOENT', newPath);\n      }\n      if (!(newParent instanceof Directory)) {\n        throw new FSError('ENOTDIR', newPath);\n      }\n    }\n    oldParent.removeItem(oldName);\n    newParent.addItem(newName, oldItem);\n  });\n};\n\n/**\n * Rename a file.\n * @param {string} oldPath Old pathname.\n * @param {string} newPath New pathname.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {undefined}\n */\nBinding.prototype.renameSync = function (oldPath, newPath, ctx) {\n  return this.rename(oldPath, newPath, undefined, ctx);\n};\n\n/**\n * Read a directory.\n * @param {string} dirpath Path to directory.\n * @param {string} encoding The encoding ('utf-8' or 'buffer').\n * @param {boolean} withFileTypes whether or not to return fs.Dirent objects\n * @param {function(Error, (Array.<string>|Array.<Buffer>)} callback Callback\n *     (optional) called with any error or array of items in the directory.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {Array<string> | Array<Buffer>} Array of items in directory (if sync).\n */\nBinding.prototype.readdir = function (\n  dirpath,\n  encoding,\n  withFileTypes,\n  callback,\n  ctx\n) {\n  markSyscall(ctx, 'scandir');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    dirpath = deBuffer(dirpath);\n    let dpath = dirpath;\n    let dir = this._system.getItem(dirpath);\n    while (dir instanceof SymbolicLink) {\n      dpath = path.resolve(path.dirname(dpath), dir.getPath());\n      dir = this._system.getItem(dpath);\n    }\n    if (!dir) {\n      throw new FSError('ENOENT', dirpath);\n    }\n    if (!(dir instanceof Directory)) {\n      throw new FSError('ENOTDIR', dirpath);\n    }\n    if (!dir.canRead()) {\n      throw new FSError('EACCES', dirpath);\n    }\n\n    let list = dir.list();\n    if (encoding === 'buffer') {\n      list = list.map(function (item) {\n        return Buffer.from(item);\n      });\n    }\n\n    if (withFileTypes === true) {\n      const types = list.map(function (name) {\n        const stats = dir.getItem(name).getStats();\n\n        return getDirentType(stats.mode);\n      });\n      list = [list, types];\n    }\n\n    return list;\n  });\n};\n\n/**\n * Read file as utf8 string.\n * @param {string} name file to write.\n * @param {number} flags Flags.\n * @return {string} the file content.\n */\nBinding.prototype.readFileUtf8 = function (name, flags) {\n  const fd = this.open(name, flags);\n  const descriptor = this.getDescriptorById(fd);\n\n  if (!descriptor.isRead()) {\n    throw new FSError('EBADF');\n  }\n  const file = descriptor.getItem();\n  if (file instanceof Directory) {\n    throw new FSError('EISDIR');\n  }\n  if (!(file instanceof File)) {\n    // deleted or not a regular file\n    throw new FSError('EBADF');\n  }\n  const content = file.getContent();\n  return content.toString('utf8');\n};\n\n/**\n * Write a utf8 string.\n * @param {string} filepath file to write.\n * @param {string} data data to write to filepath.\n * @param {number} flags Flags.\n * @param {number} mode Mode.\n */\nBinding.prototype.writeFileUtf8 = function (filepath, data, flags, mode) {\n  const destFd = this.open(filepath, flags, mode);\n  this.writeBuffer(destFd, data, 0, data.length);\n};\n\n/**\n * Create a directory.\n * @param {string} pathname Path to new directory.\n * @param {number} mode Permissions.\n * @param {boolean} recursive Recursively create deep directory. (added in nodejs v10+)\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.mkdir = function (pathname, mode, recursive, callback, ctx) {\n  markSyscall(ctx, 'mkdir');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const item = this._system.getItem(pathname);\n    if (item) {\n      if (recursive && item instanceof Directory) {\n        // silently pass existing folder in recursive mode\n        return;\n      }\n      throw new FSError('EEXIST', pathname);\n    }\n\n    const _mkdir = function (_pathname) {\n      const parentDir = path.dirname(_pathname);\n      let parent = this._system.getItem(parentDir);\n      if (!parent) {\n        if (!recursive) {\n          throw new FSError('ENOENT', _pathname);\n        }\n        parent = _mkdir(parentDir, true);\n      }\n      this.access(parentDir, parseInt('0002', 8));\n      const dir = new Directory();\n      if (mode) {\n        dir.setMode(mode);\n      }\n      return parent.addItem(path.basename(_pathname), dir);\n    }.bind(this);\n\n    _mkdir(pathname);\n  });\n};\n\n/**\n * Remove a directory.\n * @param {string} pathname Path to directory.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.rmdir = function (pathname, callback, ctx) {\n  markSyscall(ctx, 'rmdir');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const item = this._system.getItem(pathname);\n    if (!item) {\n      throw new FSError('ENOENT', pathname);\n    }\n    if (!(item instanceof Directory)) {\n      throw new FSError('ENOTDIR', pathname);\n    }\n    if (item.list().length > 0) {\n      throw new FSError('ENOTEMPTY', pathname);\n    }\n    this.access(path.dirname(pathname), parseInt('0002', 8));\n    const parent = this._system.getItem(path.dirname(pathname));\n    parent.removeItem(path.basename(pathname));\n  });\n};\n\nconst PATH_CHARS =\n  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\n\nconst MAX_ATTEMPTS = 62 * 62 * 62;\n\n/**\n * Create a directory based on a template.\n * See http://web.mit.edu/freebsd/head/lib/libc/stdio/mktemp.c\n * @param {string} prefix Path template (trailing Xs will be replaced).\n * @param {string} encoding The encoding ('utf-8' or 'buffer').\n * @param {function(Error, string)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.mkdtemp = function (prefix, encoding, callback, ctx) {\n  if (encoding && typeof encoding !== 'string') {\n    callback = encoding;\n    encoding = 'utf-8';\n  }\n\n  markSyscall(ctx, 'mkdtemp');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    prefix = prefix.replace(/X{0,6}$/, 'XXXXXX');\n    const parentPath = path.dirname(prefix);\n    const parent = this._system.getItem(parentPath);\n    if (!parent) {\n      throw new FSError('ENOENT', prefix);\n    }\n    if (!(parent instanceof Directory)) {\n      throw new FSError('ENOTDIR', prefix);\n    }\n    this.access(parentPath, parseInt('0002', 8));\n    const template = path.basename(prefix);\n    let unique = false;\n    let count = 0;\n    let name;\n    while (!unique && count < MAX_ATTEMPTS) {\n      let position = template.length - 1;\n      let replacement = '';\n      while (template.charAt(position) === 'X') {\n        replacement += PATH_CHARS.charAt(\n          Math.floor(PATH_CHARS.length * Math.random())\n        );\n        position -= 1;\n      }\n      const candidate = template.slice(0, position + 1) + replacement;\n      if (!parent.getItem(candidate)) {\n        name = candidate;\n        unique = true;\n      }\n      count += 1;\n    }\n    if (!name) {\n      throw new FSError('EEXIST', prefix);\n    }\n    const dir = new Directory();\n    parent.addItem(name, dir);\n    let uniquePath = path.join(parentPath, name);\n    if (encoding === 'buffer') {\n      uniquePath = Buffer.from(uniquePath);\n    }\n    return uniquePath;\n  });\n};\n\n/**\n * Truncate a file.\n * @param {number} fd File descriptor.\n * @param {number} len Number of bytes.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.ftruncate = function (fd, len, callback, ctx) {\n  markSyscall(ctx, 'ftruncate');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    if (!descriptor.isWrite()) {\n      throw new FSError('EINVAL');\n    }\n    const file = descriptor.getItem();\n    if (!(file instanceof File)) {\n      throw new FSError('EINVAL');\n    }\n    const content = file.getContent();\n    const newContent = Buffer.alloc(len);\n    content.copy(newContent);\n    file.setContent(newContent);\n  });\n};\n\n/**\n * Legacy support.\n * @param {number} fd File descriptor.\n * @param {number} len Number of bytes.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n */\nBinding.prototype.truncate = Binding.prototype.ftruncate;\n\n/**\n * Change user and group owner.\n * @param {string} pathname Path.\n * @param {number} uid User id.\n * @param {number} gid Group id.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.chown = function (pathname, uid, gid, callback, ctx) {\n  markSyscall(ctx, 'chown');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const item = this._system.getItem(pathname);\n    if (!item) {\n      throw new FSError('ENOENT', pathname);\n    }\n    item.setUid(uid);\n    item.setGid(gid);\n  });\n};\n\n/**\n * Change user and group owner.\n * @param {number} fd File descriptor.\n * @param {number} uid User id.\n * @param {number} gid Group id.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.fchown = function (fd, uid, gid, callback, ctx) {\n  markSyscall(ctx, 'fchown');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    const item = descriptor.getItem();\n    item.setUid(uid);\n    item.setGid(gid);\n  });\n};\n\n/**\n * Change permissions.\n * @param {string} pathname Path.\n * @param {number} mode Mode.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.chmod = function (pathname, mode, callback, ctx) {\n  markSyscall(ctx, 'chmod');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const item = this._system.getItem(pathname);\n    if (!item) {\n      throw new FSError('ENOENT', pathname);\n    }\n    item.setMode(mode);\n  });\n};\n\n/**\n * Change permissions.\n * @param {number} fd File descriptor.\n * @param {number} mode Mode.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.fchmod = function (fd, mode, callback, ctx) {\n  markSyscall(ctx, 'fchmod');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    const item = descriptor.getItem();\n    item.setMode(mode);\n  });\n};\n\n/**\n * Delete a named item.\n * @param {string} pathname Path to item.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.unlink = function (pathname, callback, ctx) {\n  markSyscall(ctx, 'unlink');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const item = this._system.getItem(pathname);\n    if (!item) {\n      throw new FSError('ENOENT', pathname);\n    }\n    if (item instanceof Directory) {\n      throw new FSError('EPERM', pathname);\n    }\n    const parent = this._system.getItem(path.dirname(pathname));\n    parent.removeItem(path.basename(pathname));\n  });\n};\n\n/**\n * Delete a named item.\n * @param {string} pathname Path to item.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.unlinkSync = function (pathname, ctx) {\n  return this.unlink(pathname, undefined, ctx);\n};\n\n/**\n * Update timestamps.\n * @param {string} pathname Path to item.\n * @param {number} atime Access time (in seconds).\n * @param {number} mtime Modification time (in seconds).\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.utimes = function (pathname, atime, mtime, callback, ctx) {\n  markSyscall(ctx, 'utimes');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    let filepath = deBuffer(pathname);\n    let item = this._system.getItem(filepath);\n    let links = 0;\n    while (item instanceof SymbolicLink) {\n      if (links > MAX_LINKS) {\n        throw new FSError('ELOOP', filepath);\n      }\n      filepath = path.resolve(path.dirname(filepath), item.getPath());\n      item = this._system.getItem(filepath);\n      ++links;\n    }\n    if (!item) {\n      throw new FSError('ENOENT', pathname);\n    }\n    item.setATime(new Date(atime * 1000));\n    item.setMTime(new Date(mtime * 1000));\n  });\n};\n\n/**\n * Update timestamps.\n * @param {string} pathname Path to item.\n * @param {number} atime Access time (in seconds).\n * @param {number} mtime Modification time (in seconds).\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.lutimes = function (pathname, atime, mtime, callback, ctx) {\n  markSyscall(ctx, 'utimes');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const item = this._system.getItem(pathname);\n    if (!item) {\n      throw new FSError('ENOENT', pathname);\n    }\n    // lutimes doesn't follow symlink\n    item.setATime(new Date(atime * 1000));\n    item.setMTime(new Date(mtime * 1000));\n  });\n};\n\n/**\n * Update timestamps.\n * @param {number} fd File descriptor.\n * @param {number} atime Access time (in seconds).\n * @param {number} mtime Modification time (in seconds).\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.futimes = function (fd, atime, mtime, callback, ctx) {\n  markSyscall(ctx, 'futimes');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    const descriptor = this.getDescriptorById(fd);\n    let item = descriptor.getItem();\n    let filepath = this._system.getFilepath(item);\n    let links = 0;\n    while (item instanceof SymbolicLink) {\n      if (links > MAX_LINKS) {\n        throw new FSError('ELOOP', filepath);\n      }\n      filepath = path.resolve(path.dirname(filepath), item.getPath());\n      item = this._system.getItem(filepath);\n      ++links;\n    }\n    item.setATime(new Date(atime * 1000));\n    item.setMTime(new Date(mtime * 1000));\n  });\n};\n\n/**\n * Synchronize in-core state with storage device.\n * @param {number} fd File descriptor.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.fsync = function (fd, callback, ctx) {\n  markSyscall(ctx, 'fsync');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    this.getDescriptorById(fd);\n  });\n};\n\n/**\n * Synchronize in-core metadata state with storage device.\n * @param {number} fd File descriptor.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.fdatasync = function (fd, callback, ctx) {\n  markSyscall(ctx, 'fdatasync');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    this.getDescriptorById(fd);\n  });\n};\n\n/**\n * Create a hard link.\n * @param {string} srcPath The existing file.\n * @param {string} destPath The new link to create.\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.link = function (srcPath, destPath, callback, ctx) {\n  markSyscall(ctx, 'link');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    srcPath = deBuffer(srcPath);\n    destPath = deBuffer(destPath);\n    const item = this._system.getItem(srcPath);\n    if (!item) {\n      throw new FSError('ENOENT', srcPath);\n    }\n    if (item instanceof Directory) {\n      throw new FSError('EPERM', srcPath);\n    }\n    if (this._system.getItem(destPath)) {\n      throw new FSError('EEXIST', destPath);\n    }\n    const parent = this._system.getItem(path.dirname(destPath));\n    if (!parent) {\n      throw new FSError('ENOENT', destPath);\n    }\n    if (!(parent instanceof Directory)) {\n      throw new FSError('ENOTDIR', destPath);\n    }\n    parent.addItem(path.basename(destPath), item);\n  });\n};\n\n/**\n * Create a symbolic link.\n * @param {string} srcPath Path from link to the source file.\n * @param {string} destPath Path for the generated link.\n * @param {string} type Ignored (used for Windows only).\n * @param {function(Error)} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.symlink = function (srcPath, destPath, type, callback, ctx) {\n  markSyscall(ctx, 'symlink');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    srcPath = deBuffer(srcPath);\n    destPath = deBuffer(destPath);\n    if (this._system.getItem(destPath)) {\n      throw new FSError('EEXIST', destPath);\n    }\n    const parent = this._system.getItem(path.dirname(destPath));\n    if (!parent) {\n      throw new FSError('ENOENT', destPath);\n    }\n    if (!(parent instanceof Directory)) {\n      throw new FSError('ENOTDIR', destPath);\n    }\n    const link = new SymbolicLink();\n    link.setPath(srcPath);\n    parent.addItem(path.basename(destPath), link);\n  });\n};\n\n/**\n * Create a symbolic link.\n * @param {string} srcPath Path from link to the source file.\n * @param {string} destPath Path for the generated link.\n * @param {string} type Ignored (used for Windows only).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.symlinkSync = function (srcPath, destPath, type, ctx) {\n  return this.symlink(srcPath, destPath, type, undefined, ctx);\n};\n\n/**\n * Read the contents of a symbolic link.\n * @param {string} pathname Path to symbolic link.\n * @param {string} encoding The encoding ('utf-8' or 'buffer').\n * @param {function(Error, (string|Buffer))} callback Optional callback.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {string|Buffer} Symbolic link contents (path to source).\n */\nBinding.prototype.readlink = function (pathname, encoding, callback, ctx) {\n  if (encoding && typeof encoding !== 'string') {\n    // this would not happend in nodejs v10+\n    callback = encoding;\n    encoding = 'utf-8';\n  }\n\n  markSyscall(ctx, 'readlink');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    pathname = deBuffer(pathname);\n    const link = this._system.getItem(pathname);\n    if (!link) {\n      throw new FSError('ENOENT', pathname);\n    }\n    if (!(link instanceof SymbolicLink)) {\n      throw new FSError('EINVAL', pathname);\n    }\n    let linkPath = link.getPath();\n    if (encoding === 'buffer') {\n      linkPath = Buffer.from(linkPath);\n    }\n    return linkPath;\n  });\n};\n\n/**\n * Stat an item.\n * @param {string} filepath Path.\n * @param {boolean} bigint Use BigInt.\n * @param {function(Error, Float64Array|BigUint64Array)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {Float64Array|BigUint64Array|undefined} Stats or undefined (if sync).\n */\nBinding.prototype.lstat = function (filepath, bigint, callback, ctx) {\n  markSyscall(ctx, 'lstat');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    filepath = deBuffer(filepath);\n    const item = this._system.getItem(filepath);\n    if (!item) {\n      throw new FSError('ENOENT', filepath);\n    }\n    const stats = item.getStats(bigint);\n    fillStats(stats, bigint);\n    return stats;\n  });\n};\n\n/**\n * Tests user permissions.\n * @param {string} filepath Path.\n * @param {number} mode Mode.\n * @param {function(Error)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.access = function (filepath, mode, callback, ctx) {\n  markSyscall(ctx, 'access');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    filepath = deBuffer(filepath);\n    let item = this._system.getItem(filepath);\n    let links = 0;\n    while (item instanceof SymbolicLink) {\n      if (links > MAX_LINKS) {\n        throw new FSError('ELOOP', filepath);\n      }\n      filepath = path.resolve(path.dirname(filepath), item.getPath());\n      item = this._system.getItem(filepath);\n      ++links;\n    }\n    if (!item) {\n      throw new FSError('ENOENT', filepath);\n    }\n    if (mode && process.getuid && process.getgid) {\n      if (mode & constants.R_OK && !item.canRead()) {\n        throw new FSError('EACCES', filepath);\n      }\n      if (mode & constants.W_OK && !item.canWrite()) {\n        throw new FSError('EACCES', filepath);\n      }\n      if (mode & constants.X_OK && !item.canExecute()) {\n        throw new FSError('EACCES', filepath);\n      }\n    }\n  });\n};\n\n/**\n * Tests user permissions.\n * @param {string} filepath Path.\n * @param {number} mode Mode.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.accessSync = function (filepath, mode, ctx) {\n  return this.access(filepath, mode, undefined, ctx);\n};\n\n/**\n * Tests whether or not the given path exists.\n * @param {string} filepath Path.\n * @param {function(Error)} callback Callback (optional).\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.exists = function (filepath, callback, ctx) {\n  markSyscall(ctx, 'exists');\n\n  return maybeCallback(normalizeCallback(callback), ctx, this, function () {\n    filepath = deBuffer(filepath);\n    const item = this._system.getItem(filepath);\n\n    if (item) {\n      if (item instanceof SymbolicLink) {\n        return this.exists(item.getPath(), callback, ctx);\n      }\n      return true;\n    }\n    return false;\n  });\n};\n\n/**\n * Tests whether or not the given path exists.\n * @param {string} filepath Path.\n * @param {object} ctx Context object (optional), only for nodejs v10+.\n * @return {*} The return if no callback is provided.\n */\nBinding.prototype.existsSync = function (filepath, ctx) {\n  return this.exists(filepath, undefined, ctx);\n};\n\n/**\n * Not yet implemented.\n * @type {function()}\n */\nBinding.prototype.StatWatcher = notImplemented;\n\n/**\n * Export the binding constructor.\n * @type {function()}\n */\nmodule.exports = Binding;\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;CAEA,MAAM,iBAAe,OAAO;CAC5B,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM,EAAC;CACP,MAAM,sBAAoB,YAAY;CACtC,MAAM,EAAC,cAAc;CAErB,MAAM,gBAAgB;GACnB,UAAU,UAAU,UAAU;GAC9B,UAAU,UAAU,UAAU;GAC9B,UAAU,UAAU,UAAU;GAC9B,UAAU,UAAU,UAAU;GAC9B,UAAU,UAAU,UAAU;GAC9B,UAAU,UAAU,UAAU;GAC9B,UAAU,WAAW,UAAU;EACjC;;CAGD,MAAM,YAAY,QAAQ,QAAQ,KAAK;CACvC,MAAM,eAAe,UAAU;CAC/B,IAAI;CACJ,IAAI;AACJ,KAAI,UAAU,YAAY;AACxB,eAAa,UAAU;AACvB,qBAAmB,UAAU;;CAG/B,MAAM,YAAY;;;;;;;;;;CAWlB,SAAS,cAAc,UAAU,KAAK,SAAS,MAAM;EACnD,IAAI,MAAM;EACV,IAAI;AAEJ,MAAI,YAAY,SAAS,EAAE;AAEzB,OAAI;AACF,UAAM,KAAK,KAAK,QAAQ;YACjB,GAAG;AACV,UAAM;;AAER,UAAO,IAAI,QAAQ,SAAU,SAAS,QAAQ;AAC5C,YAAQ,SAAS,WAAY;AAC3B,SAAI,IACF,QAAO,IA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