FileHandle

external interface FileHandle(source)

Properties

Link copied to clipboard
abstract external val fd: Double

The numeric file descriptor managed by the {FileHandle} object.

Functions

Link copied to clipboard
abstract suspend external fun appendFile(data: Uint8Array<*>): Void
abstract suspend external fun appendFile(data: Uint8Array<*>, options: BufferEncoding? = definedExternally): Void
abstract suspend external fun appendFile(data: Uint8Array<*>, options: FileHandleAppendFileAsyncOptions? = definedExternally): Void
abstract suspend external fun appendFile(data: String, options: BufferEncoding? = definedExternally): Void
abstract suspend external fun appendFile(data: String, options: FileHandleAppendFileAsyncOptions? = definedExternally): Void

Alias of filehandle.writeFile().

abstract suspend external fun appendFile(data: String): Void
Link copied to clipboard
abstract external fun appendFileAsync(data: Uint8Array<*>): Promise<Void>
abstract external fun appendFileAsync(data: String): Promise<Void>
abstract external fun appendFileAsync(data: Uint8Array<*>, options: BufferEncoding? = definedExternally): Promise<Void>
abstract external fun appendFileAsync(data: Uint8Array<*>, options: FileHandleAppendFileAsyncOptions? = definedExternally): Promise<Void>
abstract external fun appendFileAsync(data: String, options: BufferEncoding? = definedExternally): Promise<Void>
abstract external fun appendFileAsync(data: String, options: FileHandleAppendFileAsyncOptions? = definedExternally): Promise<Void>

Alias of filehandle.writeFile().

Link copied to clipboard
abstract suspend external fun chmod(mode: Mode): Void
Link copied to clipboard
abstract external fun chmodAsync(mode: Mode): Promise<Void>

Modifies the permissions on the file. See chmod(2).

Link copied to clipboard
abstract suspend external fun chown(uid: Number, gid: Number): Void
Link copied to clipboard
abstract external fun chownAsync(uid: Number, gid: Number): Promise<Void>

Changes the ownership of the file. A wrapper for chown(2).

Link copied to clipboard
abstract suspend external fun close(): Void
Link copied to clipboard
abstract external fun closeAsync(): Promise<Void>

Closes the file handle after waiting for any pending operation on the handle to complete.

Link copied to clipboard
abstract external fun createReadStream(options: CreateReadStreamOptions = definedExternally): ReadStream

Unlike the 16 KiB default highWaterMark for a stream.Readable, the stream returned by this method has a default highWaterMark of 64 KiB.

Link copied to clipboard
abstract external fun createWriteStream(options: CreateWriteStreamOptions = definedExternally): WriteStream

options may also include a start option to allow writing data at some position past the beginning of the file, allowed values are in the \[0, Number.MAX_SAFE_INTEGER\] range. Modifying a file rather than replacing it may require the flags open option to be set to r+ rather than the default r. The encoding can be any one of those accepted by Buffer.

Link copied to clipboard
abstract suspend external fun datasync(): Void
Link copied to clipboard
abstract external fun datasyncAsync(): Promise<Void>

Forces all currently queued I/O operations associated with the file to the operating system's synchronized I/O completion state. Refer to the POSIX fdatasync(2) documentation for details.

Link copied to clipboard
abstract suspend external fun <T : ArrayBufferView<*>> read(options: ReadOptionsWithBuffer<T> = definedExternally): FileReadResult<T>
abstract suspend external fun <T : ArrayBufferView<*>> read(buffer: T, options: ReadOptions = definedExternally): FileReadResult<T>
abstract suspend external fun <T : ArrayBufferView<*>> read(buffer: T, offset: Double? = definedExternally, length: Double? = definedExternally, position: ReadPosition? = definedExternally): FileReadResult<T>
Link copied to clipboard
abstract external fun readableWebStream(options: ReadableWebStreamOptions = definedExternally): ReadableStream<*>

Returns a byte-oriented ReadableStream that may be used to read the file's contents.

Link copied to clipboard
abstract external fun <T : ArrayBufferView<*>> readAsync(options: ReadOptionsWithBuffer<T> = definedExternally): Promise<FileReadResult<T>>
abstract external fun <T : ArrayBufferView<*>> readAsync(buffer: T, options: ReadOptions = definedExternally): Promise<FileReadResult<T>>

abstract external fun <T : ArrayBufferView<*>> readAsync(buffer: T, offset: Double? = definedExternally, length: Double? = definedExternally, position: ReadPosition? = definedExternally): Promise<FileReadResult<T>>

Reads data from the file and stores that in the given buffer.

Link copied to clipboard
abstract suspend external fun readFile(): Any
abstract suspend external fun readFile(options: FileHandleReadFileBufferAsyncOptions? = definedExternally): NonSharedBuffer
abstract suspend external fun readFile(options: FileHandleReadFileStringAsyncOptions): String

abstract suspend external fun readFile(options: BufferEncoding): String
abstract suspend external fun readFile(options: BufferEncoding? = definedExternally): Any
abstract suspend external fun readFile(options: FileHandleReadFileAsyncOptions? = definedExternally): Any

Asynchronously reads the entire contents of a file. The underlying file will not be closed automatically. The FileHandle must have been opened for reading.

Link copied to clipboard
abstract external fun readFileAsync(): Promise<Any>
abstract external fun readFileAsync(options: BufferEncoding): Promise<String>
abstract external fun readFileAsync(options: BufferEncoding? = definedExternally): Promise<Any>
abstract external fun readFileAsync(options: FileHandleReadFileAsyncOptions? = definedExternally): Promise<Any>

Asynchronously reads the entire contents of a file. The underlying file will not be closed automatically. The FileHandle must have been opened for reading.

abstract external fun readFileAsync(options: FileHandleReadFileBufferAsyncOptions? = definedExternally): Promise<NonSharedBuffer>

Asynchronously reads the entire contents of a file.

Link copied to clipboard
abstract external fun readLines(options: CreateReadStreamOptions = definedExternally): _Interface

Convenience method to create a readline interface and stream over the file. See filehandle.createReadStream() for the options.

Link copied to clipboard
abstract suspend external fun <TBuffers : ReadonlyArray<ArrayBufferView<*>>> readv(buffers: TBuffers, position: Number = definedExternally): ReadVResult<TBuffers>
Link copied to clipboard
abstract external fun <TBuffers : ReadonlyArray<ArrayBufferView<*>>> readvAsync(buffers: TBuffers, position: Number = definedExternally): Promise<ReadVResult<TBuffers>>

Read from a file and write to an array of ArrayBufferView s

Link copied to clipboard
abstract suspend external fun stat(opts: FileHandleStatBigIntOpts): BigIntStats
abstract suspend external fun stat(opts: FileHandleStatOpts = definedExternally): Stats
abstract suspend external fun stat(opts: StatOptions = definedExternally): Any
Link copied to clipboard
abstract external fun statAsync(opts: FileHandleStatBigIntOpts): Promise<BigIntStats>
abstract external fun statAsync(opts: FileHandleStatOpts = definedExternally): Promise<Stats>
abstract external fun statAsync(opts: StatOptions = definedExternally): Promise<Any>
Link copied to clipboard
abstract suspend external fun sync(): Void
Link copied to clipboard
abstract external fun syncAsync(): Promise<Void>

Request that all data for the open file descriptor is flushed to the storage device. The specific implementation is operating system and device specific. Refer to the POSIX fsync(2) documentation for more detail.

Link copied to clipboard
abstract suspend external fun truncate(len: Number = definedExternally): Void
Link copied to clipboard
abstract external fun truncateAsync(len: Number = definedExternally): Promise<Void>

Truncates the file.

Link copied to clipboard
abstract suspend external fun utimes(atime: TimeLike, mtime: TimeLike): Void
Link copied to clipboard
abstract external fun utimesAsync(atime: TimeLike, mtime: TimeLike): Promise<Void>

Change the file system timestamps of the object referenced by the FileHandle then fulfills the promise with no arguments upon success.

Link copied to clipboard
abstract suspend external fun <TBuffer : Uint8Array<*>> write(buffer: TBuffer, options: FileHandleWriteAsyncOptions = definedExternally): FileHandleWriteResultPayload<TBuffer>
abstract suspend external fun write(data: String, position: Double? = definedExternally, encoding: BufferEncoding? = definedExternally): FileHandleWriteStringResultPayload
abstract suspend external fun <TBuffer : ArrayBufferView<*>> write(buffer: TBuffer, offset: Double? = definedExternally, length: Double? = definedExternally, position: Double? = definedExternally): FileHandleWriteViewResultPayload<TBuffer>
Link copied to clipboard
abstract external fun <TBuffer : Uint8Array<*>> writeAsync(buffer: TBuffer, options: FileHandleWriteAsyncOptions = definedExternally): Promise<FileHandleWriteResultPayload<TBuffer>>
abstract external fun writeAsync(data: String, position: Double? = definedExternally, encoding: BufferEncoding? = definedExternally): Promise<FileHandleWriteStringResultPayload>

abstract external fun <TBuffer : ArrayBufferView<*>> writeAsync(buffer: TBuffer, offset: Double? = definedExternally, length: Double? = definedExternally, position: Double? = definedExternally): Promise<FileHandleWriteViewResultPayload<TBuffer>>

Write buffer to the file.

Link copied to clipboard
abstract suspend external fun writeFile(data: Uint8Array<*>): Void
abstract suspend external fun writeFile(data: Uint8Array<*>, options: BufferEncoding? = definedExternally): Void
abstract suspend external fun writeFile(data: Uint8Array<*>, options: FileHandleWriteFileAsyncOptions? = definedExternally): Void
abstract suspend external fun writeFile(data: String, options: BufferEncoding? = definedExternally): Void
abstract suspend external fun writeFile(data: String, options: FileHandleWriteFileAsyncOptions? = definedExternally): Void

Asynchronously writes data to a file, replacing the file if it already exists. data can be a string, a buffer, an AsyncIterable, or an Iterable object. The promise is fulfilled with no arguments upon success.

abstract suspend external fun writeFile(data: String): Void
Link copied to clipboard
abstract external fun writeFileAsync(data: Uint8Array<*>): Promise<Void>
abstract external fun writeFileAsync(data: String): Promise<Void>
abstract external fun writeFileAsync(data: Uint8Array<*>, options: BufferEncoding? = definedExternally): Promise<Void>
abstract external fun writeFileAsync(data: Uint8Array<*>, options: FileHandleWriteFileAsyncOptions? = definedExternally): Promise<Void>
abstract external fun writeFileAsync(data: String, options: BufferEncoding? = definedExternally): Promise<Void>
abstract external fun writeFileAsync(data: String, options: FileHandleWriteFileAsyncOptions? = definedExternally): Promise<Void>

Asynchronously writes data to a file, replacing the file if it already exists. data can be a string, a buffer, an AsyncIterable, or an Iterable object. The promise is fulfilled with no arguments upon success.

Link copied to clipboard
abstract suspend external fun <TBuffers : ReadonlyArray<ArrayBufferView<*>>> writev(buffers: TBuffers, position: Number = definedExternally): WriteVResult<TBuffers>
Link copied to clipboard
abstract external fun <TBuffers : ReadonlyArray<ArrayBufferView<*>>> writevAsync(buffers: TBuffers, position: Number = definedExternally): Promise<WriteVResult<TBuffers>>

Write an array of ArrayBufferView s to the file.