Dart API Referencedart:ioDirectory

Directory Interface

Directory objects are used for working with directories.

Constructors

Code new Directory.fromPath(Path path) #

Creates a directory object from a Path object. The path is either an absolute path, or it is a relative path which is interpreted relative to the directory in which the Dart VM was started.

Directory.fromPath(Path path);

Code new Directory(String path) #

Creates a directory object. The path is either an absolute path, or it is a relative path which is interpreted relative to the directory in which the Dart VM was started.

Directory(String path);

Code new Directory.current() #

Creates a directory object pointing to the current working directory.

Directory.current();

Methods

Code Future<Directory> create() #

Creates the directory with this name if it does not exist. Returns a Future<Directory> that completes with this directory once it has been created.

Future<Directory> create();

Code void createSync() #

Synchronously creates the directory with this name if it does not exist. Throws an exception if the directory already exists.

void createSync();

Code Future<Directory> createTemp() #

Creates a temporary directory with a name based on the current path. This name and path is used as a template, and additional characters are appended to it by the call to make a unique directory name. If the path is the empty string, a default system temp directory and name are used for the template.

Returns a Future<Directory> that completes with the newly created temporary directory.

Future<Directory> createTemp();

Code Directory createTempSync() #

Synchronously creates a temporary directory with a name based on the current path. This name and path is used as a template, and additional characters are appended to it by the call to make a unique directory name. If the path is the empty string, a default system temp directory and name are used for the template. Returns the newly created temporary directory.

Directory createTempSync();

Code Future<Directory> delete() #

Deletes the directory with this name. The directory must be empty. Returns a Future<Directory> that completes with this directory when the deletion is done.

Future<Directory> delete();

Code Future<Directory> deleteRecursively() #

Deletes this directory and all sub-directories and files in the directories. Returns a Future<Directory> that completes with this directory when the deletion is done.

Future<Directory> deleteRecursively();

Code void deleteRecursivelySync() #

Synchronously deletes this directory and all sub-directories and files in the directories. Throws an exception if the directory cannot be deleted.

void deleteRecursivelySync();

Code void deleteSync() #

Synchronously deletes the directory with this name. The directory must be empty. Throws an exception if the directory cannot be deleted.

void deleteSync();

Code Future<bool> exists() #

Check whether a directory with this name already exists. Returns a Future<bool> that completes with the result.

Future<bool> exists();

Code bool existsSync() #

Synchronously check whether a directory with this name already exists.

bool existsSync();

Code DirectoryLister list([bool recursive]) #

List the sub-directories and files of this Directory. Optionally recurse into sub-directories. Returns a DirectoryLister object representing the active listing operation. Handlers for files and directories should be registered on this DirectoryLister object.

DirectoryLister list([bool recursive]);

Code Future<Directory> rename(String newPath) #

Rename this directory. Returns a Future<Directory> that completes with a Directory instance for the renamed directory.

If newPath identifies an existing directory, that directory is replaced. If newPath identifies an existing file the operation fails and the future completes with an exception.

Future<Directory> rename(String newPath);

Code Directory renameSync(String newPath) #

Synchronously rename this directory. Returns a Directory instance for the renamed directory.

If newPath identifies an existing directory, that directory is replaced. If newPath identifies an existing file the operation fails and an exception is thrown.

Directory renameSync(String newPath);

Fields

Code final String path #

Gets the path of this directory.

final String path;