> ## 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.

# File

# Class: File

Defined in: [index.d.ts:388](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L388)

Represents a file handle.

## Constructors

### Constructor

> **new File**(`path`, `createMissing`): `File`

Defined in: [index.d.ts:396](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L396)

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](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L412)

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](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L419)

Deletes the file, invalidating the handle.

#### Returns

`void`

***

### extension()

> **extension**(): `string` | `null`

Defined in: [index.d.ts:423](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L423)

Returns the file extension, if any.

#### Returns

`string` | `null`

***

### isReadonly()

> **isReadonly**(): `boolean`

Defined in: [index.d.ts:432](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L432)

Returns whether the file is read-only.

#### Returns

`boolean`

***

### modified()

> **modified**(): `number`

Defined in: [index.d.ts:430](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L430)

Returns the last modification time as milliseconds since the Unix
epoch.

#### Returns

`number`

***

### moveTo()

> **moveTo**(`dest`): `void`

Defined in: [index.d.ts:417](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L417)

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](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L421)

Returns the file name (last component of the path).

#### Returns

`string`

***

### path()

> **path**(): `string`

Defined in: [index.d.ts:398](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L398)

Returns the resolved absolute path.

#### Returns

`string`

***

### read()

> **read**(): `string`

Defined in: [index.d.ts:400](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L400)

Reads the file and returns its trimmed contents.

#### Returns

`string`

***

### rename()

> **rename**(`newName`): `void`

Defined in: [index.d.ts:410](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L410)

Renames the file in place (same parent directory).

#### Parameters

##### newName

`string`

#### Returns

`void`

***

### size()

> **size**(): `number`

Defined in: [index.d.ts:425](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L425)

Returns the file size in bytes.

#### Returns

`number`

***

### write()

> **write**(`content`, `append`): `void`

Defined in: [index.d.ts:408](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L408)

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`
