{"version":3,"file":"descriptor.cjs","names":[],"sources":["../../../../../node_modules/mock-fs/lib/descriptor.js"],"sourcesContent":["'use strict';\n\nconst constants = require('constants');\n\n/**\n * Create a new file descriptor.\n * @param {number} flags Flags.\n * @param {boolean} isPromise descriptor was opened via fs.promises\n * @class\n */\nfunction FileDescriptor(flags, isPromise = false) {\n  /**\n   * Flags.\n   * @type {number}\n   */\n  this._flags = flags;\n\n  /**\n   * File system item.\n   * @type {Item}\n   */\n  this._item = null;\n\n  /**\n   * Current file position.\n   * @type {number}\n   */\n  this._position = 0;\n\n  this._isPromise = isPromise;\n}\n\n/**\n * Set the item.\n * @param {Item} item File system item.\n */\nFileDescriptor.prototype.setItem = function (item) {\n  this._item = item;\n};\n\n/**\n * Get the item.\n * @return {Item} File system item.\n */\nFileDescriptor.prototype.getItem = function () {\n  return this._item;\n};\n\n/**\n * Get the current file position.\n * @return {number} File position.\n */\nFileDescriptor.prototype.getPosition = function () {\n  return this._position;\n};\n\n/**\n * Set the current file position.\n * @param {number} position File position.\n */\nFileDescriptor.prototype.setPosition = function (position) {\n  this._position = position;\n};\n\n/**\n * Check if file opened for appending.\n * @return {boolean} Opened for appending.\n */\nFileDescriptor.prototype.isAppend = function () {\n  return (this._flags & constants.O_APPEND) === constants.O_APPEND;\n};\n\n/**\n * Check if file opened for creation.\n * @return {boolean} Opened for creation.\n */\nFileDescriptor.prototype.isCreate = function () {\n  return (this._flags & constants.O_CREAT) === constants.O_CREAT;\n};\n\n/**\n * Check if file opened for reading.\n * @return {boolean} Opened for reading.\n */\nFileDescriptor.prototype.isRead = function () {\n  return (this._flags & constants.O_WRONLY) !== constants.O_WRONLY;\n};\n\n/**\n * Check if file opened for writing.\n * @return {boolean} Opened for writing.\n */\nFileDescriptor.prototype.isWrite = function () {\n  return (\n    (this._flags & constants.O_WRONLY) === constants.O_WRONLY ||\n    (this._flags & constants.O_RDWR) === constants.O_RDWR\n  );\n};\n\n/**\n * Check if file opened for truncating.\n * @return {boolean} Opened for truncating.\n */\nFileDescriptor.prototype.isTruncate = function () {\n  return (this._flags & constants.O_TRUNC) === constants.O_TRUNC;\n};\n\n/**\n * Check if file opened with exclusive flag.\n * @return {boolean} Opened with exclusive.\n */\nFileDescriptor.prototype.isExclusive = function () {\n  return (this._flags & constants.O_EXCL) === constants.O_EXCL;\n};\n\n/**\n * Check if the file descriptor was opened as a promise\n * @return {boolean} Opened from fs.promise\n */\nFileDescriptor.prototype.isPromise = function () {\n  return this._isPromise;\n};\n\n/**\n * Export the constructor.\n * @type {function()}\n */\nmodule.exports = FileDescriptor;\n"],"x_google_ignoreList":[0],"mappings":";;;;;;CAEA,MAAM,YAAY,QAAQ,YAAY;;;;;;;CAQtC,SAAS,eAAe,OAAO,YAAY,OAAO;;;;;AAKhD,OAAK,SAAS;;;;;AAMd,OAAK,QAAQ;;;;;AAMb,OAAK,YAAY;AAEjB,OAAK,aAAa;;;;;;AAOpB,gBAAe,UAAU,UAAU,SAAU,MAAM;AACjD,OAAK,QAAQ;;;;;;AAOf,gBAAe,UAAU,UAAU,WAAY;AAC7C,SAAO,KAAK;;;;;;AAOd,gBAAe,UAAU,cAAc,WAAY;AACjD,SAAO,KAAK;;;;;;AAOd,gBAAe,UAAU,cAAc,SAAU,UAAU;AACzD,OAAK,YAAY;;;;;;AAOnB,gBAAe,UAAU,WAAW,WAAY;AAC9C,UAAQ,KAAK,SAAS,UAAU,cAAc,UAAU;;;;;;AAO1D,gBAAe,UAAU,WAAW,WAAY;AAC9C,UAAQ,KAAK,SAAS,UAAU,aAAa,UAAU;;;;;;AAOzD,gBAAe,UAAU,SAAS,WAAY;AAC5C,UAAQ,KAAK,SAAS,UAAU,cAAc,UAAU;;;;;;AAO1D,gBAAe,UAAU,UAAU,WAAY;AAC7C,UACG,KAAK,SAAS,UAAU,cAAc,UAAU,aAChD,KAAK,SAAS,UAAU,YAAY,UAAU;;;;;;AAQnD,gBAAe,UAAU,aAAa,WAAY;AAChD,UAAQ,KAAK,SAAS,UAAU,aAAa,UAAU;;;;;;AAOzD,gBAAe,UAAU,cAAc,WAAY;AACjD,UAAQ,KAAK,SAAS,UAAU,YAAY,UAAU;;;;;;AAOxD,gBAAe,UAAU,YAAY,WAAY;AAC/C,SAAO,KAAK;;;;;;AAOd,QAAO,UAAU"}