trait Fs extends Object

File I/O is provided by simple wrappers around standard POSIX functions. To use this module do require('fs'). All the methods have asynchronous and synchronous forms.

The asynchronous form always takes a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined.

When using the synchronous form any exceptions are immediately thrown. You can use try/catch to handle exceptions or allow them to bubble up.

Annotations
@JSType() @native()
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Fs
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def access(path: Path, callback: FsCallback0): Unit

    Tests a user's permissions for the file specified by path.

    Tests a user's permissions for the file specified by path. mode is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values.

    • fs.F_OK - File is visible to the calling process. This is useful for determining if a file exists, but says nothing about rwx permissions. Default if no mode is specified.
    • FSConstants.R_OK - File can be read by the calling process.
    • FSConstants.W_OK - File can be written by the calling process.
    • FSConstants.X_OK - File can be executed by the calling process. This has no effect on Windows (will behave like F_OK).
    path

    the path (Buffer | String)

    callback

    is a callback function that is invoked with a possible error argument. If any of the accessibility checks fail, the error argument will be populated.

    Example:
    1. fs.access(path[, mode], callback)

  5. def access(path: Path, mode: FileMode, callback: FsCallback0): Unit

    Tests a user's permissions for the file specified by path.

    Tests a user's permissions for the file specified by path. mode is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values.

    • fs.F_OK - File is visible to the calling process. This is useful for determining if a file exists, but says nothing about rwx permissions. Default if no mode is specified.
    • FSConstants.R_OK - File can be read by the calling process.
    • FSConstants.W_OK - File can be written by the calling process.
    • FSConstants.X_OK - File can be executed by the calling process. This has no effect on Windows (will behave like F_OK).
    path

    the path (Buffer | String)

    mode

    the optional mode

    callback

    is a callback function that is invoked with a possible error argument. If any of the accessibility checks fail, the error argument will be populated.

    Example:
    1. fs.access(path[, mode], callback)

  6. def accessSync(path: Path): Unit
  7. def accessSync(path: Path, mode: FileMode): Unit

    Synchronous version of fs.access().

    Synchronous version of fs.access(). This throws if any accessibility checks fail, and does nothing otherwise.

    path

    the path (Buffer | String)

    mode

    the optional mode

    Example:
    1. fs.accessSync(path[, mode])

  8. def appendFile(path: FileDescriptor, data: String, callback: FsCallback0): Unit
  9. def appendFile(path: FileDescriptor, data: Buffer, callback: FsCallback0): Unit
  10. def appendFile(path: Path, data: String, callback: FsCallback0): Unit
  11. def appendFile(path: Path, data: Buffer, callback: FsCallback0): Unit

    Asynchronously append data to a file, creating the file if it does not yet exist.

    Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer.

    path

    the filename or file descriptor (Buffer | String | Number)

    data

    the data to append (Buffer | String)

    callback

    the callback function

    Example:
    1. fs.appendFile(file, data[, options], callback)

  12. def appendFile(file: FileDescriptor, data: String, options: FileAppendOptions, callback: FsCallback0): Unit
  13. def appendFile(file: FileDescriptor, data: Buffer, options: FileAppendOptions, callback: FsCallback0): Unit
  14. def appendFile(file: Path, data: String, options: FileAppendOptions, callback: FsCallback0): Unit
  15. def appendFile(file: Path, data: Buffer, options: FileAppendOptions, callback: FsCallback0): Unit

    Asynchronously append data to a file, creating the file if it does not yet exist.

    Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer.

    file

    the filename or file descriptor (Buffer | String | Number)

    data

    the data to append (Buffer | String)

    options

    the optional append settings

    callback

    the callback function

    Example:
    1. fs.appendFile(file, data[, options], callback)

  16. def appendFileSync(path: FileDescriptor, data: String): Unit
  17. def appendFileSync(path: FileDescriptor, data: Buffer): Unit
  18. def appendFileSync(path: FileDescriptor, data: String, options: FileAppendOptions): Unit
  19. def appendFileSync(path: FileDescriptor, data: Buffer, options: FileAppendOptions): Unit
  20. def appendFileSync(path: Path, data: String): Unit
  21. def appendFileSync(path: Path, data: Buffer): Unit
  22. def appendFileSync(path: Path, data: String, options: FileAppendOptions): Unit
  23. def appendFileSync(path: Path, data: Buffer, options: FileAppendOptions): Unit

    The synchronous version of fs.appendFile().

    The synchronous version of fs.appendFile().

    path

    the filename or file descriptor (Buffer | String | Number)

    data

    the data to append (Buffer | String)

    options

    the optional append settings

    returns

    undefined.

  24. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  25. def chmod(path: Path, mode: FileMode, callback: FsCallback0): Unit

    Asynchronous chmod(2).

    Asynchronous chmod(2). No arguments other than a possible exception are given to the completion callback.

    path

    the file or directory path (Buffer | String)

    mode

    the file or directory mode

    callback

    the completion callback.

  26. def chmodSync(path: Path, mode: FileMode): Unit

    Synchronous chmod(2).

    Synchronous chmod(2).

    path

    the file or directory path (Buffer | String)

    mode

    the file or directory mode

    returns

    undefined.

  27. def chown(path: Path, uid: UID, gid: GID, callback: FsCallback0): Unit

    Asynchronous chown(2).

    Asynchronous chown(2). No arguments other than a possible exception are given to the completion callback.

    path

    the file or directory path (Buffer | String)

    uid

    the user ID

    gid

    the group ID

    callback

    the completion callback.

  28. def chownSync(path: Path, uid: UID, gid: GID): Unit

    Synchronous chown(2).

    Synchronous chown(2).

    path

    the file or directory path (Buffer | String)

    uid

    the user ID

    gid

    the group ID

    returns

    undefined.

  29. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  30. def close(fd: FileDescriptor, callback: FsCallback0): Unit

    Asynchronous close(2).

    Asynchronous close(2). No arguments other than a possible exception are given to the completion callback.

    Example:
    1. fs.close(fd, callback)

  31. def closeSync(fd: FileDescriptor): Unit

    Synchronous close(2).

    Synchronous close(2).

    returns

    undefined.

    Example:
    1. fs.closeSync(fd)

  32. def constants: FSConstants

    Returns an object containing commonly used constants for file system operations

    Returns an object containing commonly used constants for file system operations

    returns

    an object containing commonly used constants for file system operations

  33. def copyFile(src: Path, dest: Path, callback: FsCallback0): Unit

    Asynchronously copies src to dest.

    Asynchronously copies src to dest. By default, dest is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.

    flags is an optional integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.

    src

    the source filename to copy

    dest

    the destination filename of the copy operation

    callback

    the callback function

    Example:
    1. fs.copyFile(src, dest[, flags], callback)
  34. def copyFile(src: Path, dest: Path, mode: FileMode, callback: FsCallback0): Unit

    Asynchronously copies src to dest.

    Asynchronously copies src to dest. By default, dest is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.

    flags is an optional integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.

    src

    the source filename to copy

    dest

    the destination filename of the copy operation

    mode

    the modifiers for copy operation. Default: 0

    callback

    the callback function

    Example:
    1. fs.copyFile(src, dest[, flags], callback)
  35. def copyFileSync(src: Path, dest: Path, mode: FileMode): Unit

    Synchronously copies src to dest.

    Synchronously copies src to dest. By default, dest is overwritten if it already exists.

    Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.

    flags is an optional integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.

    src

    the source filename to copy

    dest

    the destination filename of the copy operation

    mode

    the modifiers for copy operation. Default: 0

    Example:
    1. fs.copyFileSync(src, dest[, flags])
  36. def createReadStream(path: Path): ReadStream
  37. def createReadStream(path: Path, options: FileInputOptions): ReadStream

    Returns a new ReadStream object.

    Returns a new ReadStream object. (See Readable Stream). Be aware that, unlike the default value set for highWaterMark on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter.

    path

    the path (Buffer | String)

    options

    the optional stream options

    Example:
    1. fs.createReadStream(path[, options])

  38. def createWriteStream(path: Path): WriteStream
  39. def createWriteStream(path: Path, options: FileOutputOptions): WriteStream

    Returns a new WriteStream object.

    Returns a new WriteStream object.

    path

    the path (Buffer | String)

    options

    the optional stream options

    Example:
    1. fs.createWriteStream(path[, options])

  40. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  41. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  42. def existsSync(path: Path): Boolean

    fs.exists() should not be used to check if a file exists before calling fs.open().

    fs.exists() should not be used to check if a file exists before calling fs.open(). Doing so introduces a race condition since other processes may change the file's state between the two calls. Instead, user code should call fs.open() directly and handle the error raised if the file is non-existent.

    Example:
    1. fs.existsSync(path)

  43. def fchmod(fd: FileDescriptor, mode: FileMode, callback: FsCallback0): Unit

    Asynchronous fchmod(2).

    Asynchronous fchmod(2). No arguments other than a possible exception are given to the completion callback.

    Example:
    1. fs.fchmod(fd, mode, callback)

  44. def fchmodSync(fd: FileDescriptor, mode: FileMode): Unit

    Synchronous fchmod(2).

    Synchronous fchmod(2).

    returns

    undefined.

    Example:
    1. fs.fchmodSync(fd, mode)

  45. def fchown(fd: FileDescriptor, uid: UID, gid: GID, callback: FsCallback0): Unit

    Asynchronous fchown(2).

    Asynchronous fchown(2). No arguments other than a possible exception are given to the completion callback.

    fd

    the file descriptor

    uid

    the user ID

    gid

    the group ID

    callback

    the completion callback.

  46. def fchownSync(fd: FileDescriptor, uid: UID, gid: GID): Unit

    Synchronous fchown(2).

    Synchronous fchown(2).

    fd

    the file descriptor

    uid

    the user ID

    gid

    the group ID

  47. def fdatasync(fd: FileDescriptor, callback: FsCallback0): Unit

    Asynchronous fdatasync(2).

    Asynchronous fdatasync(2). No arguments other than a possible exception are given to the completion callback.

    Example:
    1. fs.fdatasync(fd, callback)

  48. def fdatasyncSync(fd: FileDescriptor): Unit

    Synchronous fdatasync(2).

    Synchronous fdatasync(2).

    returns

    undefined.

    Example:
    1. fs.fdatasyncSync(fd)

  49. def fstat(fd: FileDescriptor, options: StatOptions, callback: FsCallback1[StatsVariant]): Unit
  50. def fstat(fd: FileDescriptor, callback: FsCallback1[Stats]): Unit

    Asynchronous fstat(2).

    Asynchronous fstat(2). The callback gets two arguments (err, stats) where stats is an fs.Stats object. fstat() is identical to stat(), except that the file to be stat-ed is specified by the file descriptor fd.

    fd

    the file descriptor

    callback

    the completion callback.

  51. def fstatSync(fd: FileDescriptor): Stats
  52. def fstatSync(fd: FileDescriptor, options: StatOptions): StatsVariant

    Synchronous fstat(2).

    Synchronous fstat(2).

    fd

    the file descriptor

    returns

    an instance of fs.Stats.

  53. def fsync(fd: FileDescriptor, callback: FsCallback0): Unit

    Asynchronous fsync(2).

    Asynchronous fsync(2). No arguments other than a possible exception are given to the completion callback.

    fd

    the file descriptor

    callback

    the completion callback.

  54. def fsyncSync(fd: FileDescriptor): Unit

    Synchronous fsync(2).

    Synchronous fsync(2).

    fd

    the file descriptor

    returns

    undefined.

  55. def ftruncate(fd: FileDescriptor, length: Int, callback: FsCallback0): Unit

    Asynchronous ftruncate(2).

    Asynchronous ftruncate(2). No arguments other than a possible exception are given to the completion callback. If the file referred to by the file descriptor was larger than length bytes, only the first length bytes will be retained in the file.

    fd

    the file descriptor

    length

    the desired length

    callback

    the completion callback.

  56. def ftruncate(fd: FileDescriptor, callback: FsCallback0): Unit

    Asynchronous ftruncate(2).

    Asynchronous ftruncate(2). No arguments other than a possible exception are given to the completion callback. If the file referred to by the file descriptor was larger than length bytes, only the first length bytes will be retained in the file.

    fd

    the file descriptor

    callback

    the completion callback.

  57. def ftruncateSync(fd: FileDescriptor): Unit
  58. def ftruncateSync(fd: FileDescriptor, length: Int): Unit

    Synchronous ftruncate(2).

    Synchronous ftruncate(2).

    fd

    the file descriptor

    length

    the desired length

    returns

    undefined.

  59. def futimes(fd: FileDescriptor, atime: Time, mtime: Time, callback: Function): Unit

    Change the file timestamps of a file referenced by the supplied file descriptor.

    Change the file timestamps of a file referenced by the supplied file descriptor.

    Example:
    1. fs.futimes(fd, atime, mtime, callback)

  60. def futimesSync(fd: FileDescriptor, atime: Time, mtime: Time): Unit

    Synchronous version of fs.futimes().

    Synchronous version of fs.futimes().

    returns

    undefined.

    Example:
    1. fs.futimesSync(fd, atime, mtime)

  61. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  62. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  63. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  64. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  65. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  66. def lchmod(path: Path, mode: FileMode, callback: FsCallback0): Unit

    Asynchronous lchmod(2).

    Asynchronous lchmod(2). No arguments other than a possible exception are given to the completion callback.

    Example:
    1. fs.lchmod(path, mode, callback)

  67. def lchmodSync(path: Path, mode: FileMode): Unit

    Synchronous lchmod(2).

    Synchronous lchmod(2).

    path

    the path (Buffer | String)

    mode

    the mode (Integer)

    returns

    undefined.

    Example:
    1. fs.lchmodSync(path, mode)

  68. def lchown(path: Path, uid: UID, gid: GID, callback: FsCallback0): Unit

    Asynchronous lchown(2).

    Asynchronous lchown(2). No arguments other than a possible exception are given to the completion callback.

    path

    the path (Buffer | String)

    uid

    the user ID

    gid

    the group ID

    callback

    the completion callback.

    Example:
    1. fs.lchown(path, uid, gid, callback)

  69. def lchownSync(path: Path, uid: UID, gid: GID): Unit

    Synchronous chown(2).

    Synchronous chown(2).

    path

    the path (Buffer | String)

    uid

    the user ID

    gid

    the group ID

    returns

    undefined.

  70. def link(existingPath: Path, newPath: Path, callback: FsCallback0): Unit

    Asynchronous link(2).

    Asynchronous link(2). No arguments other than a possible exception are given to the completion callback.

    existingPath

    the existing path

    newPath

    the new path

    callback

    the completion callback.

    Example:
    1. fs.link(srcpath, dstpath, callback)

  71. def linkSync(existingPath: Path, newPath: Path): Unit

    Synchronous link(2).

    Synchronous link(2).

    existingPath

    the existing path

    newPath

    the new path

    returns

    undefined.

  72. def lstat(path: Path, callback: FsCallback1[Stats]): Unit

    Asynchronous lstat(2).

    Asynchronous lstat(2). lstat() is identical to stat(), except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to.

    path

    the path (Buffer | String)

    callback

    The callback gets two arguments (err, stats) where stats is a fs.Stats object.

  73. def lstat(path: Path, options: StatOptions, callback: FsCallback1[StatsVariant]): Unit
  74. def lstatSync(path: Path, options: StatOptions): StatsVariant
  75. def lstatSync(path: Path): Stats

    Synchronous lstat(2).

    Synchronous lstat(2).

    path

    the path (Buffer | String)

    returns

    an instance of fs.Stats.

  76. def lutimes(path: Path, atime: Time, mtime: Time, callback: FsCallback0): Unit
  77. def lutimesSync(path: Path, atime: Time, mtime: Time): Unit
  78. def mkdir(path: Path, callback: FsCallback0): Unit

    Asynchronous mkdir(2).

    Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0o777.

    Example:
    1. fs.mkdir(path[, mode], callback)

  79. def mkdir(path: Path, mode: MkdirOptions, callback: FsRecursiveCallback0): Unit
  80. def mkdir(path: Path, mode: MkdirOptions, callback: FsCallback0): Unit

    Asynchronous mkdir(2).

    Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0o777.

    After v13.11.0, in recursive mode, the callback now receives the first created path as an 2nd argument.

    Example:
    1. fs.mkdir(path[, mode], callback)

  81. def mkdir(path: Path, mode: FileMode, callback: FsCallback0): Unit

    Asynchronous mkdir(2).

    Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0o777.

    Example:
    1. fs.mkdir(path[, mode], callback)

  82. def mkdirSync(path: Path, mode: MkdirOptions): UndefOr[String]

    returns

    After Node.js v13.11.0, in recursive mode, the first created path is returned now. Otherwise undefined

  83. def mkdirSync(path: Path): Unit
  84. def mkdirSync(path: Path, mode: FileMode): Unit

    Synchronous mkdir(2).

    Synchronous mkdir(2).

    path

    the path

    mode

    the mode

  85. def mkdtemp(prefix: String, callback: FsCallback1[String]): Unit

    Creates a unique temporary directory.

    Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. The created folder path is passed as a string to the callback's second parameter. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.

    prefix

    the prefix

    callback

    the callback

    Example:
    1. fs.mkdtemp(prefix[, options], callback)

  86. def mkdtemp(prefix: String, options: FileEncodingOptions, callback: FsCallback1[String]): Unit
  87. def mkdtemp(prefix: String, options: String, callback: FsCallback1[String]): Unit

    Creates a unique temporary directory.

    Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. The created folder path is passed as a string to the callback's second parameter. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.

    prefix

    the prefix

    options

    the optional encoding setting

    callback

    the callback

    Example:
    1. fs.mkdtemp(prefix[, options], callback)

  88. def mkdtempSync(prefix: String): String
  89. def mkdtempSync(prefix: String, options: FileEncodingOptions): String
  90. def mkdtempSync(prefix: String, options: String): String

    The synchronous version of fs.mkdtemp().

    The synchronous version of fs.mkdtemp(). Returns the created folder path. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.

    prefix

    the prefix

    options

    the optional encoding setting

  91. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  92. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  93. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  94. def open(path: Path, callback: FsCallback1[FileDescriptor]): Unit
  95. def open(path: Path, flags: Flags, callback: FsCallback1[FileDescriptor]): Unit

    Asynchronous file open.

    Asynchronous file open. See open(2).

    path

    the path (Buffer | String)

    flags

    flags can be:

    • 'r' - Open file for reading. An exception occurs if the file does not exist.
    • 'r+' - Open file for reading and writing. An exception occurs if the file does not exist.
    • 'rs+' - Open file for reading and writing in synchronous mode. Instructs the operating system to bypass the local file system cache. This is primarily useful for opening files on NFS mounts as it allows you to skip the potentially stale local cache. It has a very real impact on I/O performance so don't use this flag unless you need it. Note that this doesn't turn fs.open() into a synchronous blocking call. If that's what you want then you should be using fs.openSync()
    • 'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
    • 'wx' - Like 'w' but fails if path exists.
    • 'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
    • 'wx+' - Like 'w+' but fails if path exists.
    • 'a' - Open file for appending. The file is created if it does not exist.
    • 'ax' - Like 'a' but fails if path exists.
    • 'a+' - Open file for reading and appending. The file is created if it does not exist.
    • 'ax+' - Like 'a+' but fails if path exists.
    callback

    the callback gets two arguments (err, fd)

    Example:
    1. fs.open(path, flags[, mode], callback)

  96. def open(path: Path, flags: Flags, mode: FileMode, callback: FsCallback1[FileDescriptor]): Unit

    Asynchronous file open.

    Asynchronous file open. See open(2).

    path

    the path (Buffer | String)

    flags

    flags can be:

    • 'r' - Open file for reading. An exception occurs if the file does not exist.
    • 'r+' - Open file for reading and writing. An exception occurs if the file does not exist.
    • 'rs+' - Open file for reading and writing in synchronous mode. Instructs the operating system to bypass the local file system cache. This is primarily useful for opening files on NFS mounts as it allows you to skip the potentially stale local cache. It has a very real impact on I/O performance so don't use this flag unless you need it. Note that this doesn't turn fs.open() into a synchronous blocking call. If that's what you want then you should be using fs.openSync()
    • 'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
    • 'wx' - Like 'w' but fails if path exists.
    • 'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
    • 'wx+' - Like 'w+' but fails if path exists.
    • 'a' - Open file for appending. The file is created if it does not exist.
    • 'ax' - Like 'a' but fails if path exists.
    • 'a+' - Open file for reading and appending. The file is created if it does not exist.
    • 'ax+' - Like 'a+' but fails if path exists.
    mode

    sets the file mode (permission and sticky bits), but only if the file was created. It defaults to 0666, readable and writable.

    callback

    the callback gets two arguments (err, fd)

    Example:
    1. fs.open(path, flags[, mode], callback)

  97. def openSync(path: Path): FileDescriptor
  98. def openSync(path: Path, flags: Flags): FileDescriptor
  99. def openSync(path: Path, flags: Flags, mode: FileMode): FileDescriptor

    Synchronous version of fs.open().

    Synchronous version of fs.open().

    path

    the path (Buffer | String)

    flags

    the flags

    mode

    the file mode

    returns

    an integer representing the file descriptor.

    Example:
    1. fs.openSync(path, flags[, mode])

  100. def opendir(path: Path, callback: FsCallback1[Dir[String]]): Unit
  101. def opendir(path: Path, options: OpendirOptions, callback: FsCallback1[|[Dir[String], Dir[Buffer]]]): Unit
  102. def opendirSync(path: Path): Dir[String]
  103. def opendirSync(path: Path, options: OpendirOptions): |[Dir[String], Dir[Buffer]]
  104. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  105. def read(fd: FileDescriptor, options: ReadOptions, callback: FsCallback2[Int, Buffer]): Unit
  106. def read(fd: FileDescriptor, buffer: BufferLike, offset: |[Int, Null], length: |[Int, Null], position: |[Int, Null], callback: FsCallback2[Int, Buffer]): Unit

    Read data from the file specified by fd.

    Read data from the file specified by fd.

    fd

    is the file descriptor

    buffer

    is the buffer that the data will be written to.

    offset

    is the offset in the buffer to start writing at.

    length

    is an integer specifying the number of bytes to read.

    position

    is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.

    callback

    the callback is given the three arguments, (err, bytesRead, buffer).

  107. def readFile(file: FileDescriptor, callback: FsCallback1[Buffer]): Unit
  108. def readFile(file: Path, callback: FsCallback1[Buffer]): Unit

    Asynchronously reads the entire contents of a file.

    Asynchronously reads the entire contents of a file.

    file

    filename or file descriptor

    callback

    The callback is passed two arguments (err, data), where data is the contents of the file. If no encoding is specified, then the raw buffer is returned.

    Example:
    1. fs.readFile(file[, options], callback)

  109. def readFile(file: FileDescriptor, encoding: String, callback: FsCallback1[String]): Unit
  110. def readFile(file: Path, encoding: String, callback: FsCallback1[String]): Unit

    Asynchronously reads the entire contents of a file.

    Asynchronously reads the entire contents of a file.

    file

    filename or file descriptor

    encoding

    the encoding (default = null)

    callback

    The callback is passed two arguments (err, data), where data is the contents of the file. If no encoding is specified, then the raw buffer is returned.

    Example:
    1. fs.readFile(file[, options], callback)

  111. def readFile(file: FileDescriptor, options: ReadFileOptions, callback: FsCallback1[Output]): Unit
  112. def readFile(file: Path, options: ReadFileOptions, callback: FsCallback1[Output]): Unit

    Asynchronously reads the entire contents of a file.

    Asynchronously reads the entire contents of a file.

    file

    filename or file descriptor

    options

    the optional settings

    callback

    The callback is passed two arguments (err, data), where data is the contents of the file. If no encoding is specified, then the raw buffer is returned.

    Example:
    1. fs.readFile(file[, options], callback)

  113. def readFileSync(file: FileDescriptor): Buffer
  114. def readFileSync(file: Path): Buffer

    Synchronous version of fs.readFile.

    Synchronous version of fs.readFile.

    file

    filename or file descriptor <String> | <Buffer> | <Integer>

    returns

    the contents of the file. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

    Example:
    1. fs.readFileSync(file[, options])

  115. def readFileSync(file: FileDescriptor, options: ReadFileOptions): Output
  116. def readFileSync(file: Path, options: ReadFileOptions): Output

    Synchronous version of fs.readFile.

    Synchronous version of fs.readFile. Returns the contents of the file.

    file

    filename or file descriptor <String> | <Buffer> | <Integer>

    options

    the optional encoding <Object> | <String>

    returns

    the contents of the file. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

    Example:
    1. fs.readFileSync(file[, options])

  117. def readFileSync(file: FileDescriptor, encoding: String): String
  118. def readFileSync(file: Path, encoding: String): String

    Synchronous version of fs.readFile.

    Synchronous version of fs.readFile. Returns the contents of the file.

    file

    filename or file descriptor <String> | <Buffer> | <Integer>

    encoding

    the optional encoding <Object> | <String>

    returns

    the contents of the file. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

    Example:
    1. fs.readFileSync(file[, options])

  119. def readSync(fd: FileDescriptor, buffer: BufferLike): Unit
  120. def readSync(fd: FileDescriptor, buffer: BufferLike, offset: |[Int, Null]): Unit
  121. def readSync(fd: FileDescriptor, buffer: BufferLike, offset: |[Int, Null], length: |[Int, Null], position: |[Int, Null]): Unit
  122. def readSync(fd: FileDescriptor, buffer: BufferLike, offset: Int, length: Int, position: Int): Int
  123. def readSync(fd: FileDescriptor, buffer: Buffer, offset: Int, length: Int, position: Int): Int

    Synchronous version of fs.read().

    Synchronous version of fs.read().

    fd

    is the file descriptor

    buffer

    is the buffer that the data will be written to.

    offset

    is the offset in the buffer to start writing at.

    length

    is an integer specifying the number of bytes to read.

    position

    is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.

    returns

    the number of bytesRead.

  124. def readdir(path: Path, callback: FsCallback1[Array[String]]): Unit
  125. def readdir(path: Path, options: ReaddirOptions, callback: FsCallback1[ReaddirArrays2]): Unit
  126. def readdir(path: Path, options: FileEncodingOptions, callback: FsCallback1[ReaddirArrays]): Unit
  127. def readdir(path: Path, options: String, callback: FsCallback1[ReaddirArrays]): Unit

    Asynchronous readdir(3).

    Asynchronous readdir(3). Reads the contents of a directory.

    path

    the path (Buffer | String)

    options

    the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the filenames passed to the callback. If the encoding is set to 'buffer', the filenames returned will be passed as Buffer objects.

    callback

    the callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.

    Example:
    1. fs.readdir(path[, options], callback)

  128. def readdirSync(path: Path): Array[String]
  129. def readdirSync(path: Path, options: ReaddirOptions): ReaddirArrays2
  130. def readdirSync(path: Path, options: FileEncodingOptions): ReaddirArrays
  131. def readdirSync(path: Path, options: String): ReaddirArrays

    Synchronous readdir(3).

    Synchronous readdir(3).

    path

    the path (Buffer | String)

    options

    the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the filenames passed to the callback. If the encoding is set to 'buffer', the filenames returned will be passed as Buffer objects.

    returns

    an array of filenames excluding '.' and '..'.

  132. def readlink(path: Path, callback: FsCallback1[String]): Unit
  133. def readlink(path: Path, options: FileEncodingOptions, callback: FsCallback1[Output]): Unit
  134. def readlink(path: Path, options: String, callback: FsCallback1[Output]): Unit

    Asynchronous readlink(2).

    Asynchronous readlink(2). If the encoding is set to 'buffer', the link path returned will be passed as a Buffer object.

    path

    the path (Buffer | String)

    options

    the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the link path passed to the callback.

    callback

    the callback gets two arguments (err, linkString).

    Example:
    1. fs.readlink(path[, options], callback)

  135. def readlinkSync(path: Path): String
  136. def readlinkSync(path: Path, options: FileEncodingOptions): Output
  137. def readlinkSync(path: Path, options: String): Output

    Synchronous readlink(2).

    Synchronous readlink(2).

    path

    the path (Buffer | String)

    options

    the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the link path passed to the callback. If the encoding is set to 'buffer', the link path returned will be passed as a Buffer object.

    returns

    the symbolic link's string value.

  138. def readv(fd: FileDescriptor, buffers: Array[ArrayBufferView], callback: FsCallback2[Int, Array[ArrayBufferView]]): Unit
  139. def readv(fd: FileDescriptor, buffers: Array[ArrayBufferView], position: |[Int, Null], callback: FsCallback2[Int, Array[ArrayBufferView]]): Unit
  140. def readvSync(fd: FileDescriptor, buffers: Array[ArrayBufferView]): Int
  141. def readvSync(fd: FileDescriptor, buffers: Array[ArrayBufferView], position: Integer): Int
  142. def realpath(path: Path, callback: FsCallback1[String]): Unit

    Asynchronous realpath(2).

    Asynchronous realpath(2). The callback gets two arguments (err, resolvedPath). May use process.cwd to resolve relative paths.

    The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the path passed to the callback. If the encoding is set to 'buffer', the path returned will be passed as a Buffer object.

    Example:
    1. fs.realpath(path[, options], callback)

  143. def realpath(path: Path, options: FileEncodingOptions, callback: FsCallback1[Output]): Unit
  144. def realpath(path: Path, options: String, callback: FsCallback1[Output]): Unit

    Asynchronous realpath(2).

    Asynchronous realpath(2). May use process.cwd to resolve relative paths.

    path

    the path

    options

    The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the path passed to the callback.

    callback

    The callback gets two arguments (err, resolvedPath). If the encoding is set to 'buffer', the path returned will be passed as a Buffer object.

    Example:
    1. fs.realpath(path[, options], callback)

  145. val realpath: RealpathObject
  146. def realpathSync(path: Path): String
  147. def realpathSync(path: Path, options: String): Output
  148. def realpathSync(path: Path, options: FileEncodingOptions): Output

    Synchronous realpath(3).

    Synchronous realpath(3). Only paths that can be converted to UTF8 strings are supported. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the returned value. If the encoding is set to 'buffer', the path returned will be passed as a Buffer object.

    returns

    the resolved path.

    Example:
    1. fs.realpathSync(path[, options])

  149. val realpathSync: RealpathSyncObject
  150. def rename(oldPath: Path, newPath: Path, callback: FsCallback0): Unit

    Asynchronous rename(2).

    Asynchronous rename(2). No arguments other than a possible exception are given to the completion callback.

    Example:
    1. fs.rename(oldPath, newPath, callback)

  151. def renameSync(oldPath: Path, newPath: Path): Unit

    Synchronous rename(2).

    Synchronous rename(2).

    returns

    undefined.

    Example:
    1. fs.renameSync(oldPath, newPath)

  152. def rm(path: Path, callback: FsCallback0): Unit
  153. def rm(path: Path, options: RmOptions, callback: FsCallback0): Unit
  154. def rmSync(path: Path): Unit
  155. def rmSync(path: Path, options: RmOptions): Unit
  156. def rmdir(path: Path, options: RmdirOptions, callback: FsCallback0): Unit
  157. def rmdir(path: Path, callback: FsCallback0): Unit

    Asynchronous rmdir(2).

    Asynchronous rmdir(2). No arguments other than a possible exception are given to the completion callback.

    Example:
    1. fs.rmdir(path, callback)

  158. def rmdirSync(path: Path, options: RmdirOptions): Unit
  159. def rmdirSync(path: Path): Unit

    Synchronous rmdir(2rmdir).

    Synchronous rmdir(2rmdir).

    returns

    undefined.

    Example:
    1. fs.rmdirSync(path)

  160. def stat(path: Path, options: StatOptions, callback: FsCallback1[StatsVariant]): Unit
  161. def stat(path: Path, callback: FsCallback1[Stats]): Unit

    Asynchronous stat(2).

    Asynchronous stat(2). The callback gets two arguments (err, stats) where stats is a fs.Stats object. See the fs.Stats section for more information.

    Example:
    1. fs.stat(path, callback)

  162. def statSync(path: Path, options: StatOptions): StatsVariant
  163. def statSync(path: Path): Stats

    Synchronous stat(2).

    Synchronous stat(2). Returns an instance of fs.Stats.

    Example:
    1. fs.statSync(path)

  164. def symlink(target: Path, path: Path, callback: FsCallback0): Unit

    Asynchronous symlink(2).

    Asynchronous symlink(2). No arguments other than a possible exception are given to the completion callback. The type argument can be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using 'junction', the target argument will automatically be normalized to absolute path.

    Example:
    1. fs.symlink(target, path[, type], callback)

  165. def symlink(target: Path, path: Path, type: String, callback: FsCallback0): Unit

    Asynchronous symlink(2).

    Asynchronous symlink(2). No arguments other than a possible exception are given to the completion callback. The type argument can be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using 'junction', the target argument will automatically be normalized to absolute path.

    Example:
    1. fs.symlink(target, path[, type], callback)

  166. def symlinkSync(target: Path, path: Path): Unit
  167. def symlinkSync(target: Path, path: Path, type: String): Unit

    Synchronous symlink(2).

    Synchronous symlink(2).

    returns

    undefined.

    Example:
    1. fs.symlinkSync(target, path[, type])

  168. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  169. def toLocaleString(): String
    Definition Classes
    Object
  170. def toString(): String
    Definition Classes
    AnyRef → Any
  171. def truncate(path: Path, callback: FsCallback0): Unit
  172. def truncate(path: Path, length: Int, callback: FsCallback0): Unit

    Asynchronous truncate(2).

    Asynchronous truncate(2). No arguments other than a possible exception are given to the completion callback. A file descriptor can also be passed as the first argument. In this case, fs.ftruncate() is called.

    path

    the path <String> | <Buffer>

    length

    the length

    callback

    the completion callback.

    Example:
    1. fs.truncate(path, length, callback)

  173. def truncateSync(path: Path): Unit
  174. def truncateSync(path: Path, length: Int): Unit

    Synchronous truncate(2).

    Synchronous truncate(2). In this case, fs.ftruncateSync() is called.

    path

    the path or file descriptor - <String> | <Buffer> | <Integer>

    length

    the length

    returns

    undefined.

    Example:
    1. fs.truncateSync(path, length)

  175. def unlink(path: Path, callback: FsCallback0): Unit

    Asynchronous unlink(2).

    Asynchronous unlink(2). No arguments other than a possible exception are given to the completion callback.

    Example:
    1. fs.unlink(path, callback)

  176. def unlinkSync(path: Path): Unit

    Synchronous unlink(2).

    Synchronous unlink(2).

    returns

    undefined.

    Example:
    1. fs.unlinkSync(path)

  177. def unwatchFile(path: Path): Unit
  178. def unwatchFile(path: Path, listener: FileWatchListener): Unit

    Stop watching for changes on filename.

    Stop watching for changes on filename. If listener is specified, only that particular listener is removed. Otherwise, all listeners are removed and you have effectively stopped watching filename.

    Calling fs.unwatchFile() with a filename that is not being watched is a no-op, not an error.

    Note: fs.watch() is more efficient than fs.watchFile() and fs.unwatchFile(). fs.watch() should be used instead of fs.watchFile() and fs.unwatchFile() when possible.

    Example:
    1. fs.unwatchFile(filename[, listener])

  179. def utimes(path: Path, atime: Time, mtime: Time, callback: FsCallback0): Unit

    Change file timestamps of the file referenced by the supplied path.

    Change file timestamps of the file referenced by the supplied path.

    Note: the arguments atime and mtime of the following related functions does follow the below rules:

    If the value is a numberable string like '123456789', the value would get converted to corresponding number. If the value is NaN or Infinity, the value would get converted to Date.now().

    Example:
    1. fs.utimes(path, atime, mtime, callback)

  180. def utimesSync(path: Path, atime: Time, mtime: Time): Unit

    Synchronous version of fs.utimes().

    Synchronous version of fs.utimes().

    returns

    undefined.

    Example:
    1. fs.utimesSync(path, atime, mtime)

  181. def valueOf(): Any
    Definition Classes
    Object
  182. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  183. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  184. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  185. def watch(filename: Path): FSWatcher
  186. def watch(filename: Path, options: FSWatcherOptions): FSWatcher

    Watch for changes on filename, where filename is either a file or a directory.

    Watch for changes on filename, where filename is either a file or a directory. The returned object is a fs.FSWatcher.

    The second argument is optional. If options is provided as a string, it specifies the encoding. Otherwise options should be passed as an object.

    The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename is the name of the file which triggered the event.

    filename

    the filename (Buffer | String)

    options

    the optional settings

    returns

    a FSWatcher

    Example:
    1. fs.watch(filename[, options][, listener])

  187. def watch(filename: Path, listener: WatchListener): FSWatcher

    Watch for changes on filename, where filename is either a file or a directory.

    Watch for changes on filename, where filename is either a file or a directory. The returned object is a fs.FSWatcher.

    The second argument is optional. If options is provided as a string, it specifies the encoding. Otherwise options should be passed as an object.

    The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename is the name of the file which triggered the event.

    filename

    the filename (Buffer | String)

    listener

    the listener callback gets two arguments (eventType, filename). eventType is either 'rename' or 'change', and filename is the name of the file which triggered the event.

    returns

    a FSWatcher

    Example:
    1. fs.watch(filename[, options][, listener])

  188. def watch(filename: Path, options: FSWatcherOptions, listener: WatchListener): FSWatcher

    Watch for changes on filename, where filename is either a file or a directory.

    Watch for changes on filename, where filename is either a file or a directory. The returned object is a fs.FSWatcher.

    The second argument is optional. If options is provided as a string, it specifies the encoding. Otherwise options should be passed as an object.

    The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename is the name of the file which triggered the event.

    filename

    the filename (Buffer | String)

    options

    the optional settings

    listener

    the callback function

    returns

    a FSWatcher

    Example:
    1. fs.watch(filename[, options][, listener])

  189. def watchFile(filename: Path, listener: FileWatchListener): FSStatWatcher

    Watch for changes on filename.

    Watch for changes on filename. The callback listener will be called each time the file is accessed.

    The options argument may be omitted. If provided, it should be an object. The options object may contain a boolean named persistent that indicates whether the process should continue to run as long as files are being watched. The options object may specify an interval property indicating how often the target should be polled in milliseconds. The default is { persistent: true, interval: 5007 }.

    filename

    the filename (Buffer | String)

    listener

    the callback

  190. def watchFile(filename: Path, options: FileWatcherOptions, listener: FileWatchListener): FSStatWatcher

    Watch for changes on filename.

    Watch for changes on filename. The callback listener will be called each time the file is accessed.

    The options argument may be omitted. If provided, it should be an object. The options object may contain a boolean named persistent that indicates whether the process should continue to run as long as files are being watched. The options object may specify an interval property indicating how often the target should be polled in milliseconds. The default is { persistent: true, interval: 5007 }.

    filename

    the filename (Buffer | String)

    options

    the optional settings

    listener

    the callback

  191. def write(fd: FileDescriptor, string: String, callback: FsCallback2[Int, String]): Unit
  192. def write(fd: FileDescriptor, string: String, position: Int, callback: FsCallback2[Int, String]): Unit
  193. def write(fd: FileDescriptor, string: String, position: Int, encoding: String, callback: FsCallback2[Int, String]): Unit

    Write string to the file specified by fd.

    Write string to the file specified by fd. If string is not a string, then the value will be coerced to one. Unlike when writing buffer, the entire string must be written. No substring may be specified. This is because the byte offset of the resulting data may not be the same as the string offset. Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended. On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.

    fd

    the file descriptor

    string

    the data to write

    position

    refers to the offset from the beginning of the file where this data should be written. If typeof position !== 'number' the data will be written at the current position. See pwrite(2).

    encoding

    is the expected string encoding.

    callback

    will receive the arguments (err, written, string) where written specifies how many bytes the passed string required to be written. Note that bytes written is not the same as string characters. See Buffer.byteLength.

    Example:
    1. fs.write(fd, string[, position[, encoding]], callback)
  194. def write(fd: FileDescriptor, buffer: BufferLike, offset: |[Int, Null], length: |[Int, Null], position: |[Int, Null], callback: FsCallback2[Int, ArrayBufferView]): Unit

    Write buffer to the file specified by fd.

    Write buffer to the file specified by fd.

    Note: that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended.

    On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.

    fd

    the file descriptor

    buffer

    the buffer containing the data to write

    offset

    determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write.

    length

    the optional length of the data to write

    position

    refers to the offset from the beginning of the file where this data should be written. If typeof position !== 'number', the data will be written at the current position. See pwrite(2).

    callback

    will be given three arguments (err, written, buffer) where written specifies how many bytes were written from buffer.

    Example:
    1. fs.write(fd, buffer[, offset[, length[, position]]], callback)
  195. def writeFile(file: String, data: BufferLike, callback: FsCallback0): Unit
  196. def writeFile(file: String, data: BufferLike, options: FileWriteOptions, callback: FsCallback0): Unit
  197. def writeFile(file: String, data: String, callback: FsCallback0): Unit
  198. def writeFile(file: String, data: String, options: FileWriteOptions, callback: FsCallback0): Unit
  199. def writeFile(file: String, data: Uint8Array, callback: FsCallback0): Unit
  200. def writeFile(file: String, data: Uint8Array, options: FileWriteOptions, callback: FsCallback0): Unit

    Asynchronously writes data to a file, replacing the file if it already exists.

    Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer. The encoding option is ignored if data is a buffer. It defaults to 'utf8'

    Example:
    1. fs.writeFile(file, data[, options], callback)

  201. def writeFileSync(file: FileDescriptor, data: BufferLike): Unit
  202. def writeFileSync(file: FileDescriptor, data: BufferLike, options: FileWriteOptions): Unit
  203. def writeFileSync(file: FileDescriptor, data: String): Unit
  204. def writeFileSync(file: FileDescriptor, data: String, options: FileWriteOptions): Unit
  205. def writeFileSync(file: FileDescriptor, data: Uint8Array): Unit
  206. def writeFileSync(file: FileDescriptor, data: Uint8Array, options: FileWriteOptions): Unit
  207. def writeFileSync(file: Path, data: BufferLike): Unit
  208. def writeFileSync(file: Path, data: BufferLike, options: FileWriteOptions): Unit
  209. def writeFileSync(file: Path, data: String): Unit
  210. def writeFileSync(file: Path, data: String, options: FileWriteOptions): Unit
  211. def writeFileSync(file: Path, data: Uint8Array): Unit
  212. def writeFileSync(file: Path, data: Uint8Array, options: FileWriteOptions): Unit

    The synchronous version of fs.writeFile().

    The synchronous version of fs.writeFile().

    returns

    undefined.

    Example:
    1. fs.writeFileSync(file, data[, options])

  213. def writeSync(fd: FileDescriptor, data: String): Unit
  214. def writeSync(fd: FileDescriptor, data: String, encoding: String): Unit
  215. def writeSync(fd: FileDescriptor, data: String, position: Int): Unit
  216. def writeSync(fd: FileDescriptor, data: String, position: Int, encoding: String): Unit

    Write string to the file specified by fd.

    Write string to the file specified by fd.

    fd

    the given file descriptor

    data

    the given string

    position

    refers to the offset from the beginning of the file where this data should be written.

    encoding

    is the expected string encoding.

    Example:
    1. fs.writeSync(fd, string[, position[, encoding]])
  217. def writeSync(fd: FileDescriptor, buffer: BufferLike): Unit
  218. def writeSync(fd: FileDescriptor, buffer: BufferLike, offset: Int): Unit
  219. def writeSync(fd: FileDescriptor, buffer: BufferLike, offset: Int, length: Int): Unit
  220. def writeSync(fd: FileDescriptor, buffer: BufferLike, offset: Int, length: Int, position: Int): Unit
  221. def writeSync(fd: FileDescriptor, buffer: Uint8Array): Unit
  222. def writeSync(fd: FileDescriptor, buffer: Uint8Array, offset: Int): Unit
  223. def writeSync(fd: FileDescriptor, buffer: Uint8Array, offset: Int, length: Int): Unit
  224. def writeSync(fd: FileDescriptor, buffer: Uint8Array, offset: Int, length: Int, position: Int): Unit

    Write buffer to the file specified by fd.

    Write buffer to the file specified by fd.

    fd

    the given file descriptor

    buffer

    the given buffer

    offset

    determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write.

    length

    the optional length of the data to write

    position

    refers to the offset from the beginning of the file where this data should be written.

    Example:
    1. fs.writeSync(fd, buffer[, offset[, length[, position]]])
  225. def writev(fd: FileDescriptor, buffers: Array[ArrayBufferView], fsCallback2: FsCallback2[Int, Array[ArrayBufferView]]): Unit
  226. def writev(fd: FileDescriptor, buffers: Array[ArrayBufferView], position: |[Int, Null], fsCallback2: FsCallback2[Int, Array[ArrayBufferView]]): Unit
  227. def writevSync(fd: FileDescriptor, buffers: Array[ArrayBufferView]): Unit
  228. def writevSync(fd: FileDescriptor, buffers: Array[ArrayBufferView], position: Int): Unit

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped