Skip to content

Handle

Defined in: src/vfs/file.ts:20

Internal

new Handle(context, path, internalPath, flag, vnode): Handle

Defined in: src/vfs/file.ts:83

Creates a file handle for the vnode.

unknown

string

string

number

VNode

Handle

protected _position: number = 0

Defined in: src/vfs/file.ts:22

Current position


protected closed: boolean = false

Defined in: src/vfs/file.ts:64

Whether the file is open or closed


readonly context: unknown

Defined in: src/vfs/file.ts:84


readonly flag: number

Defined in: src/vfs/file.ts:87


readonly internalPath: string

Defined in: src/vfs/file.ts:86


readonly path: string

Defined in: src/vfs/file.ts:85


protected refs: number = 1

Defined in: src/vfs/file.ts:67

How many descriptors refer to this open file


readonly vnode: VNode

Defined in: src/vfs/file.ts:88

get protected _isSync(): boolean

Defined in: src/vfs/file.ts:91

boolean


get protected dirty(): boolean

Defined in: src/vfs/file.ts:57

Whether the file has changes which have not been written to the FS

boolean


get fs(): FileSystem

Defined in: src/vfs/file.ts:50

FileSystem


get inode(): InodeLike

Defined in: src/vfs/file.ts:45

The inode for the file. This is shared between all handles for the file via the vnode.

InodeLike


get isClosed(): boolean

Defined in: src/vfs/file.ts:76

boolean


get position(): number

Defined in: src/vfs/file.ts:33

Get the current file position.

We emulate the following bug mentioned in the Node documentation:

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.

number

The current file position.

set position(value): void

Defined in: src/vfs/file.ts:37

number

void

[asyncDispose](): Promise<void>

Defined in: src/vfs/file.ts:237

Promise<void>


[dispose](): void

Defined in: src/vfs/file.ts:95

void


chmod(mode): Promise<void>

Defined in: src/vfs/file.ts:361

number

Promise<void>


chmodSync(mode): void

Defined in: src/vfs/file.ts:208

number

void


chown(uid, gid): Promise<void>

Defined in: src/vfs/file.ts:369

number

number

Promise<void>


chownSync(uid, gid): void

Defined in: src/vfs/file.ts:216

number

number

void


close(): Promise<void>

Defined in: src/vfs/file.ts:257

Promise<void>


closeSync(): void

Defined in: src/vfs/file.ts:115

void


datasync(): Promise<void>

Defined in: src/vfs/file.ts:253

Default implementation maps to sync.

Promise<void>


datasyncSync(): void

Defined in: src/vfs/file.ts:111

Default implementation maps to syncSync.

void


protected dispose(force?): void

Defined in: src/vfs/file.ts:267

Cleans up. This will not sync the file data to the FS

boolean

void


protected disposeSync(force?): void

Defined in: src/vfs/file.ts:125

Cleans up. This will not sync the file data to the FS

boolean

void


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

Defined in: src/vfs/file.ts:334

Read data from the file.

ArrayBufferView

The buffer that the data will be written to.

number = 0

The offset within the buffer where writing will start.

number = ...

An integer specifying the number of bytes to read.

number = ...

An integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.

Promise<number>

number of bytes written


readSync(buffer, offset?, length?, position?): number

Defined in: src/vfs/file.ts:181

Read data from the file.

ArrayBufferView

The buffer that the data will be written to.

number = 0

The offset within the buffer where writing will start.

number = ...

An integer specifying the number of bytes to read.

number = ...

An integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.

number

number of bytes written


ref(): this

Defined in: src/vfs/file.ts:70

Take another reference to the open file

this


stat(): InodeLike

Defined in: src/vfs/file.ts:275

InodeLike


streamRead(options): ReadableStream

Defined in: src/vfs/file.ts:394

Create a stream for reading the file.

StreamOptions

ReadableStream

Don’t repeat ourselves with the implementation in FileSystem


streamWrite(options): WritableStream

Defined in: src/vfs/file.ts:428

Create a stream for writing the file. Chunks are written to the vnode’s cache, then synced when the stream is closed.

StreamOptions

WritableStream

Don’t repeat ourselves with the implementation in FileSystem


sync(): Promise<void>

Defined in: src/vfs/file.ts:241

Promise<void>


syncSync(): void

Defined in: src/vfs/file.ts:99

void


truncate(length): Promise<void>

Defined in: src/vfs/file.ts:281

number

Promise<void>


truncateSync(length): void

Defined in: src/vfs/file.ts:133

number

void


utimes(atime, mtime): Promise<void>

Defined in: src/vfs/file.ts:380

Change the file timestamps of the file.

number

number

Promise<void>


utimesSync(atime, mtime): void

Defined in: src/vfs/file.ts:227

Change the file timestamps of the file.

number

number

void


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

Defined in: src/vfs/file.ts:303

Write buffer to the file.

Uint8Array

Uint8Array containing the data to write to the file.

number = 0

Offset in the buffer to start reading data from.

number = ...

The amount of bytes to write to the file.

number = ...

Offset from the beginning of the file where this data should be written. If position is null, the data will be written at the current position.

Promise<number>

bytes written


writeSync(buffer, offset?, length?, position?): number

Defined in: src/vfs/file.ts:155

Write buffer to the file.

Uint8Array

Uint8Array containing the data to write to the file.

number = 0

Offset in the buffer to start reading data from.

number = ...

The amount of bytes to write to the file.

number = ...

Offset from the beginning of the file where this data should be written. If position is null, the data will be written at the current position.

number

bytes written