Skip to main content

Constructor

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

string
required
boolean
required

Returns

Directory

Methods

copyTo()

Copies the directory recursively to a new location.

Parameters

string
required

Returns

Directory

delete()

Deletes the directory recursively, invalidating the handle.

isReadonly()

Returns whether the directory is read-only.

Returns

boolean

listDirs()

Returns all subdirectories in this directory (non-recursive). Throws if any individual directory entry fails to read.

Returns

Directory[]

listFiles()

Returns all files in this directory (non-recursive). Throws if any individual directory entry fails to read.

Returns

File[]

modified()

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

Returns

number

moveTo()

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

Parameters

string
required

name()

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

Returns

string

path()

Returns the resolved absolute path.

Returns

string

rename()

Renames the directory in place (same parent directory)

Parameters

string
required

temp()

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