write

external fun <TBuffer : ArrayBufferView<*>> write(fd: Number, buffer: TBuffer, offset: Double?, length: Double?, position: Double?, callback: (err: ErrnoException?, written: Double, buffer: TBuffer) -> Unit)(source)

Write buffer to the file specified by fd.

offset determines the part of the buffer to be written, and length is an integer specifying the number of bytes 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).

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

If this method is invoked as its util.promisify() ed version, it returns a promise for an Object with bytesWritten and buffer properties.

It is unsafe to use fs.write() multiple times on the same file without waiting for the callback. For this scenario, {@link createWriteStream} is 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.

Since

v0.0.2

Parameters

position='null'


external fun <TBuffer : ArrayBufferView<*>> write(fd: Number, buffer: TBuffer, offset: Double?, length: Double?, callback: (err: ErrnoException?, written: Double, buffer: TBuffer) -> Unit)(source)

Asynchronously writes buffer to the file referenced by the supplied file descriptor.

Parameters

fd

A file descriptor.

offset

The part of the buffer to be written. If not supplied, defaults to 0.

length

The number of bytes to write. If not supplied, defaults to buffer.length - offset.


external fun <TBuffer : ArrayBufferView<*>> write(fd: Number, buffer: TBuffer, offset: Double?, callback: (err: ErrnoException?, written: Double, buffer: TBuffer) -> Unit)(source)

Asynchronously writes buffer to the file referenced by the supplied file descriptor.

Parameters

fd

A file descriptor.

offset

The part of the buffer to be written. If not supplied, defaults to 0.


external fun <TBuffer : ArrayBufferView<*>> write(fd: Number, buffer: TBuffer, callback: (err: ErrnoException?, written: Double, buffer: TBuffer) -> Unit)(source)

Asynchronously writes buffer to the file referenced by the supplied file descriptor.

Parameters

fd

A file descriptor.


external fun write(fd: Number, string: String, position: Double?, encoding: BufferEncoding?, callback: (err: ErrnoException?, written: Double, str: String) -> Unit)(source)

Asynchronously writes string to the file referenced by the supplied file descriptor.

Parameters

fd

A file descriptor.

string

A string to write.

position

The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

encoding

The expected string encoding.


external fun write(fd: Number, string: String, position: Double?, callback: (err: ErrnoException?, written: Double, str: String) -> Unit)(source)

Asynchronously writes string to the file referenced by the supplied file descriptor.

Parameters

fd

A file descriptor.

string

A string to write.

position

The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.


external fun write(fd: Number, string: String, callback: (err: ErrnoException?, written: Double, str: String) -> Unit)(source)

Asynchronously writes string to the file referenced by the supplied file descriptor.

Parameters

fd

A file descriptor.

string

A string to write.