Skip to main content

Interface: FileHandle

Properties

path

path: string

The file path.


readable

readable: ReadableStream<Uint8Array>


writable

writable: WritableStream<Uint8Array>

Methods

chmod()

chmod(mode): Promise<void>

Change permissions of the file. See fchmod(2)

Parameters

mode

number

The file mode consisting of permission, suid, sgid, and sticky bits.

Returns

Promise<void>


close()

close(): Promise<void>

Closes the file.

Returns

Promise<void>


datasync()

datasync(): Promise<void>

See fdatasync(2)

Returns

Promise<void>


read()

read(buffer, offset?): Promise<number>

Reads data into the given buffer at the given file offset. Returns the amount of read data or null for EOF.

Parameters

buffer

Uint8Array

Buffer to read data into.

offset?

number

Offset in the file to read from.

Returns

Promise<number>


stat()

stat(): Promise<StatResult>

Get the file status information. See stat(2)

Returns

Promise<StatResult>


sync()

sync(): Promise<void>

See fsync(2)

Returns

Promise<void>


truncate()

truncate(offset?): Promise<void>

Truncates the file to the given length.

Parameters

offset?

number

Length to truncate the file to.

Returns

Promise<void>


utime()

utime(atime, mtime): Promise<void>

Change the access and modification time of the file. See futimes(2)

Parameters

atime

Date

The new file access time.

mtime

Date

The new file modification time.

Returns

Promise<void>


write()

write(buffer, offset?): Promise<number>

Writes data from the given buffer at the given file offset. Returns the amount of data written.

Parameters

buffer

Uint8Array

Buffer to write.

offset?

number

Offset in the file to write to.

Returns

Promise<number>