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

> Represents a directory handle.

## Constructor

```typescript
Directory(path: string, createMissing: boolean): Directory
```

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

<ResponseField name={"path"} type={"string"} required />

<ResponseField name={"createMissing"} type={"boolean"} required />

### Returns

`Directory`

## Methods

### copyTo()

```typescript
copyTo(dest: string): Directory
```

Copies the directory recursively to a new location.

#### Parameters

<ResponseField name={"dest"} type={"string"} required />

#### Returns

`Directory`

### delete()

```typescript
delete(): void
```

Deletes the directory recursively, invalidating the handle.

### isReadonly()

```typescript
isReadonly(): boolean
```

Returns whether the directory is read-only.

#### Returns

`boolean`

### listDirs()

```typescript
listDirs(): Directory[]
```

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

Throws if any individual directory entry fails to read.

#### Returns

`Directory[]`

### listFiles()

```typescript
listFiles(): File[]
```

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

Throws if any individual directory entry fails to read.

#### Returns

`File[]`

### modified()

```typescript
modified(): number
```

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

#### Returns

`number`

### moveTo()

```typescript
moveTo(dest: string): void
```

Moves the directory to a new location
Falls back to copy + delete for cross-device moves.

#### Parameters

<ResponseField name={"dest"} type={"string"} required />

### name()

```typescript
name(): string
```

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

#### Returns

`string`

### path()

```typescript
path(): string
```

Returns the resolved absolute path.

#### Returns

`string`

### rename()

```typescript
rename(newName: string): void
```

Renames the directory in place (same parent directory)

#### Parameters

<ResponseField name={"newName"} type={"string"} required />

### temp()

```typescript
temp(): Directory
```

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`
