FileHandle

sealed external interface FileHandle(source)

Properties

Link copied to clipboard
abstract val fd: Double

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

Functions

Link copied to clipboard
abstract suspend fun appendFile(data: <Error class: unknown class><out <Error class: unknown class>>): <Error class: unknown class>
abstract suspend fun appendFile(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: BufferEncoding? = definedExternally): <Error class: unknown class>
abstract suspend fun appendFile(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: FileHandleAppendFileAsyncOptions? = definedExternally): <Error class: unknown class>
abstract suspend fun appendFile(data: String, options: BufferEncoding? = definedExternally): <Error class: unknown class>
abstract suspend fun appendFile(data: String, options: FileHandleAppendFileAsyncOptions? = definedExternally): <Error class: unknown class>

Alias of filehandle.writeFile().

abstract suspend fun appendFile(data: String): <Error class: unknown class>
Link copied to clipboard
abstract fun appendFileAsync(    data: <Error class: unknown class><out <Error class: unknown class>>): <Error class: unknown class><<Error class: unknown class>>
abstract fun appendFileAsync(data: String): <Error class: unknown class><<Error class: unknown class>>
abstract fun appendFileAsync(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: BufferEncoding? = definedExternally): <Error class: unknown class><<Error class: unknown class>>
abstract fun appendFileAsync(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: FileHandleAppendFileAsyncOptions? = definedExternally): <Error class: unknown class><<Error class: unknown class>>
abstract fun appendFileAsync(    data: String,     options: BufferEncoding? = definedExternally): <Error class: unknown class><<Error class: unknown class>>
abstract fun appendFileAsync(    data: String,     options: FileHandleAppendFileAsyncOptions? = definedExternally): <Error class: unknown class><<Error class: unknown class>>

Alias of filehandle.writeFile().

Link copied to clipboard
abstract suspend fun chmod(mode: Mode): <Error class: unknown class>
Link copied to clipboard
abstract fun chmodAsync(mode: Mode): <Error class: unknown class><<Error class: unknown class>>

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

Link copied to clipboard
abstract suspend fun chown(uid: Number, gid: Number): <Error class: unknown class>
Link copied to clipboard
abstract fun chownAsync(uid: Number, gid: Number): <Error class: unknown class><<Error class: unknown class>>

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

Link copied to clipboard
abstract suspend fun close(): <Error class: unknown class>
Link copied to clipboard
abstract fun closeAsync(): <Error class: unknown class><<Error class: unknown class>>

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

Link copied to clipboard
abstract 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 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 fun datasync(): <Error class: unknown class>
Link copied to clipboard
abstract fun datasyncAsync(): <Error class: unknown class><<Error class: unknown class>>

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 fun <T> read(options: FileReadOptions<T> = definedExternally): FileReadResult<T>
abstract suspend fun <T> read(buffer: T, options: FileReadOptions<T> = definedExternally): FileReadResult<T>
abstract suspend fun <T> read(    buffer: T,     offset: Double? = definedExternally,     length: Double? = definedExternally,     position: Double? = definedExternally): FileReadResult<T>
Link copied to clipboard
abstract fun readableWebStream(    options: ReadableWebStreamOptions = definedExternally): <Error class: unknown class><out <Error class: unknown class>>

Returns a ReadableStream that may be used to read the files data.

Link copied to clipboard
abstract fun <T> readAsync(options: FileReadOptions<T> = definedExternally): <Error class: unknown class><FileReadResult<T>>
abstract fun <T> readAsync(buffer: T, options: FileReadOptions<T> = definedExternally): <Error class: unknown class><FileReadResult<T>>

abstract fun <T> readAsync(    buffer: T,     offset: Double? = definedExternally,     length: Double? = definedExternally,     position: Double? = definedExternally): <Error class: unknown class><FileReadResult<T>>

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

Link copied to clipboard
abstract suspend fun readFile(): Any
abstract suspend fun readFile(options: FileHandleReadFileBufferAsyncOptions? = definedExternally): Buffer<*>
abstract suspend fun readFile(options: FileHandleReadFileStringAsyncOptions): String

abstract suspend fun readFile(options: BufferEncoding): String
abstract suspend fun readFile(options: BufferEncoding? = definedExternally): Any
abstract suspend 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 fun readFileAsync(): <Error class: unknown class><Any>
abstract fun readFileAsync(options: BufferEncoding): <Error class: unknown class><String>
abstract fun readFileAsync(options: BufferEncoding? = definedExternally): <Error class: unknown class><Any>
abstract fun readFileAsync(options: FileHandleReadFileAsyncOptions? = definedExternally): <Error class: unknown class><Any>
abstract fun readFileAsync(options: FileHandleReadFileStringAsyncOptions): <Error class: unknown class><String>

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 fun readFileAsync(options: FileHandleReadFileBufferAsyncOptions? = definedExternally): <Error class: unknown class><Buffer<*>>

Asynchronously reads the entire contents of a file.

Link copied to clipboard
abstract 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 fun readv(    buffers: <Error class: unknown class><<Error class: unknown class><out <Error class: unknown class>>>,     position: Number = definedExternally): ReadVResult
Link copied to clipboard
abstract fun readvAsync(    buffers: <Error class: unknown class><<Error class: unknown class><out <Error class: unknown class>>>,     position: Number = definedExternally): <Error class: unknown class><ReadVResult>

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

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

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 fun truncate(len: Number = definedExternally): <Error class: unknown class>
Link copied to clipboard
abstract fun truncateAsync(len: Number = definedExternally): <Error class: unknown class><<Error class: unknown class>>

Truncates the file.

Link copied to clipboard
abstract suspend fun utimes(atime: TimeLike, mtime: TimeLike): <Error class: unknown class>
Link copied to clipboard
abstract fun utimesAsync(atime: TimeLike, mtime: TimeLike): <Error class: unknown class><<Error class: unknown class>>

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 fun <TBuffer> write(    buffer: TBuffer,     options: FileHandleWriteAsyncOptions = definedExternally): FileHandleWriteResultPayload<TBuffer>
abstract suspend fun write(    data: String,     position: Double? = definedExternally,     encoding: BufferEncoding? = definedExternally): FileHandleWriteStringResultPayload
abstract suspend fun <TBuffer> write(    buffer: TBuffer,     offset: Double? = definedExternally,     length: Double? = definedExternally,     position: Double? = definedExternally): FileHandleWriteResultPayload<TBuffer>
Link copied to clipboard
abstract fun <TBuffer> writeAsync(    buffer: TBuffer,     options: FileHandleWriteAsyncOptions = definedExternally): <Error class: unknown class><FileHandleWriteResultPayload<TBuffer>>
abstract fun writeAsync(    data: String,     position: Double? = definedExternally,     encoding: BufferEncoding? = definedExternally): <Error class: unknown class><FileHandleWriteStringResultPayload>

abstract fun <TBuffer> writeAsync(    buffer: TBuffer,     offset: Double? = definedExternally,     length: Double? = definedExternally,     position: Double? = definedExternally): <Error class: unknown class><FileHandleWriteResultPayload<TBuffer>>

Write buffer to the file.

Link copied to clipboard
abstract suspend fun writeFile(data: <Error class: unknown class><out <Error class: unknown class>>): <Error class: unknown class>
abstract suspend fun writeFile(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: BufferEncoding? = definedExternally): <Error class: unknown class>
abstract suspend fun writeFile(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: FileHandleWriteFileAsyncOptions? = definedExternally): <Error class: unknown class>
abstract suspend fun writeFile(data: String, options: BufferEncoding? = definedExternally): <Error class: unknown class>
abstract suspend fun writeFile(data: String, options: FileHandleWriteFileAsyncOptions? = definedExternally): <Error class: unknown class>

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 fun writeFile(data: String): <Error class: unknown class>
Link copied to clipboard
abstract fun writeFileAsync(    data: <Error class: unknown class><out <Error class: unknown class>>): <Error class: unknown class><<Error class: unknown class>>
abstract fun writeFileAsync(data: String): <Error class: unknown class><<Error class: unknown class>>
abstract fun writeFileAsync(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: BufferEncoding? = definedExternally): <Error class: unknown class><<Error class: unknown class>>
abstract fun writeFileAsync(    data: <Error class: unknown class><out <Error class: unknown class>>,     options: FileHandleWriteFileAsyncOptions? = definedExternally): <Error class: unknown class><<Error class: unknown class>>
abstract fun writeFileAsync(data: String, options: BufferEncoding? = definedExternally): <Error class: unknown class><<Error class: unknown class>>
abstract fun writeFileAsync(    data: String,     options: FileHandleWriteFileAsyncOptions? = definedExternally): <Error class: unknown class><<Error class: unknown class>>

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 fun writev(    buffers: <Error class: unknown class><<Error class: unknown class><out <Error class: unknown class>>>,     position: Number = definedExternally): WriteVResult
Link copied to clipboard
abstract fun writevAsync(    buffers: <Error class: unknown class><<Error class: unknown class><out <Error class: unknown class>>>,     position: Number = definedExternally): <Error class: unknown class><WriteVResult>

Write an array of ArrayBufferView s to the file.