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

# Directory

# Class: Directory

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

Represents a directory handle.

## Constructors

### Constructor

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

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

Creates a handle to a directory at the given path.

If `create_missing` is true, the directory (and all missing
ancestors) is created when it does not already exist. If false,
the call fails when the directory does not exist.

#### Parameters

##### path

`string`

##### createMissing

`boolean`

#### Returns

`Directory`

## Methods

### copyTo()

> **copyTo**(`dest`): `Directory`

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

Copies the directory recursively to a new location.

#### Parameters

##### dest

`string`

#### Returns

`Directory`

***

### delete()

> **delete**(): `void`

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

Deletes the directory recursively, invalidating the handle.

#### Returns

`void`

***

### isReadonly()

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

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

Returns whether the directory is read-only.

#### Returns

`boolean`

***

### listDirs()

> **listDirs**(): `Directory`\[]

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

Returns all subdirectories in this directory (non-recursive).

Throws if any individual directory entry fails to read.

#### Returns

`Directory`\[]

***

### listFiles()

> **listFiles**(): [`File`](File.mdx)\[]

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

Returns all files in this directory (non-recursive).

Throws if any individual directory entry fails to read.

#### Returns

[`File`](File.mdx)\[]

***

### modified()

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

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

Returns the last modification time of the directory itself as
milliseconds since the Unix epoch.

#### Returns

`number`

***

### moveTo()

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

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

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

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

#### Returns

`string`

***

### path()

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

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

Returns the resolved absolute path.

#### Returns

`string`

***

### rename()

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

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

Renames the directory in place (same parent directory)

#### Parameters

##### newName

`string`

#### Returns

`void`

***

### temp()

> `static` **temp**(): `Directory`

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

Creates a directory with a unique name inside the system's temp
directory, returning a handle to it. The directory is **not**
automatically removed; call `delete()` when done.

#### Returns

`Directory`
