Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.simular.ai/llms.txt

Use this file to discover all available pages before exploring further.

Class: File

Defined in: index.d.ts:388 Represents a file handle.

Constructors

Constructor

new File(path, createMissing): File
Defined in: index.d.ts:396 Creates a handle to a file at the given path. If create_missing is true, the file (and all missing parent directories) is created when it does not already exist. If false, the call fails when the file does not exist.

Parameters

path
string
createMissing
boolean

Returns

File

Methods

copyTo()

copyTo(dest): File
Defined in: index.d.ts:412 Copies the file to a new location, returning a handle to the copy.

Parameters

dest
string

Returns

File

delete()

delete(): void
Defined in: index.d.ts:419 Deletes the file, invalidating the handle.

Returns

void

extension()

extension(): string | null
Defined in: index.d.ts:423 Returns the file extension, if any.

Returns

string | null

isReadonly()

isReadonly(): boolean
Defined in: index.d.ts:432 Returns whether the file is read-only.

Returns

boolean

modified()

modified(): number
Defined in: index.d.ts:430 Returns the last modification time as milliseconds since the Unix epoch.

Returns

number

moveTo()

moveTo(dest): void
Defined in: index.d.ts:417 Moves the file to a new location. Falls back to copy + delete for cross-device moves.

Parameters

dest
string

Returns

void

name()

name(): string
Defined in: index.d.ts:421 Returns the file name (last component of the path).

Returns

string

path()

path(): string
Defined in: index.d.ts:398 Returns the resolved absolute path.

Returns

string

read()

read(): string
Defined in: index.d.ts:400 Reads the file and returns its trimmed contents.

Returns

string

rename()

rename(newName): void
Defined in: index.d.ts:410 Renames the file in place (same parent directory).

Parameters

newName
string

Returns

void

size()

size(): number
Defined in: index.d.ts:425 Returns the file size in bytes.

Returns

number

write()

write(content, append): void
Defined in: index.d.ts:408 Writes content to the file. When append is true and the file already has content, a newline is inserted before appending. When append is false, the file is overwritten. Parent directories are created if needed.

Parameters

content
string
append
boolean

Returns

void