Skip to content

Handle

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

Internal

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

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

Creates a file handle for the vnode.

unknown

string

string

number

VNode

Handle

protected _position: number = 0

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

Current position


protected closed: boolean = false

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

Whether the file is open or closed


readonly context: unknown

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


readonly flag: number

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


readonly internalPath: string

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


readonly path: string

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


protected refs: number = 1

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

How many descriptors refer to this open file


readonly vnode: VNode

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

get protected _isSync(): boolean

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

boolean


get protected dirty(): boolean

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

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

boolean


get fs(): FileSystem

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

FileSystem


get inode(): InodeLike

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

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:84

boolean


get position(): number

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

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:45

number

void

[asyncDispose](): Promise<void>

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

Promise<void>


[dispose](): void

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

void


chmod(mode): Promise<void>

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

number

Promise<void>


chmodSync(mode): void

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

number

void


chown(uid, gid): Promise<void>

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

number

number

Promise<void>


chownSync(uid, gid): void

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

number

number

void


close(): Promise<void>

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

Promise<void>


closeSync(): void

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

void


datasync(): Promise<void>

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

Default implementation maps to sync.

Promise<void>


datasyncSync(): void

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

Default implementation maps to syncSync.

void


protected dispose(force?): void

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

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

boolean

void


protected disposeSync(force?): void

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

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:342

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:189

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:78

Take another reference to the open file

this


stat(): InodeLike

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

InodeLike


streamRead(options): ReadableStream

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

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:429

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:249

Promise<void>


syncSync(): void

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

void


truncate(length): Promise<void>

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

number

Promise<void>


truncateSync(length): void

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

number

void


utimes(atime, mtime): Promise<void>

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

Change the file timestamps of the file.

number

number

Promise<void>


utimesSync(atime, mtime): void

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

Change the file timestamps of the file.

number

number

void


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

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

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:163

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