open

external fun open(path: PathLike, flags: OpenMode?, mode: Mode?, callback: (err: ErrnoException?, fd: Double) -> Unit)(source)

Asynchronous file open. See the POSIX open(2) documentation for more details.

mode sets the file mode (permission and sticky bits), but only if the file was created. On Windows, only the write permission can be manipulated; see {@link chmod}.

The callback gets two arguments (err, fd).

Some characters (< > : " / \ | ? *) are reserved under Windows as documented by Naming Files, Paths, and Namespaces. Under NTFS, if the filename contains a colon, Node.js will open a file system stream, as described by this MSDN page.

Functions based on fs.open() exhibit this behavior as well:fs.writeFile(), fs.readFile(), etc.

Since

v0.0.2

Parameters

mode=0o666


external fun open(path: PathLike, flags: OpenMode?, callback: (err: ErrnoException?, fd: Double) -> Unit)(source)

Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be 0o666.

Parameters

path

A path to a file. If a URL is provided, it must use the file: protocol.

flags='r' See support of file system flags``.


external fun open(path: PathLike, callback: (err: ErrnoException?, fd: Double) -> Unit)(source)

Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be 0o666.

Parameters

path

A path to a file. If a URL is provided, it must use the file: protocol.


suspend fun open(path: PathLike): FileHandle(source)


suspend fun open(path: PathLike, flags: String = undefined.unsafeCast<Nothing>(), mode: Mode = undefined.unsafeCast<Nothing>()): FileHandle(source)
suspend fun open(path: PathLike, flags: Double = undefined.unsafeCast<Nothing>(), mode: Mode = undefined.unsafeCast<Nothing>()): FileHandle(source)

Opens a FileHandle.

Refer to the POSIX open(2) documentation for more detail.

Some characters (< > : " / \ | ? *) are reserved under Windows as documented by Naming Files, Paths, and Namespaces. Under NTFS, if the filename contains a colon, Node.js will open a file system stream, as described by this MSDN page.

Since

v10.0.0

Return

Fulfills with a {FileHandle} object.

Parameters

mode=0o666 Sets the file mode (permission and sticky bits) if the file is created.