Directory
Import :
const Directory = brackets.getModule("filesystem/Directory")
Directory
Kind: global class
- Directory
- new Directory(fullPath, fileSystem)
- .isEmptyAsync() ⇒
Promise.<boolean>
- .unlinkEmptyDirectoryAsync() ⇒
Promise.<void>
- .getContentsAsync(filterNothing) ⇒
Object
- .getContents(callback, filterNothing)
- .createAsync() ⇒
Promise.<FileSystemStats>
- .create([callback])
new Directory(fullPath, fileSystem)
Model for a file system Directory.
This class should not be instantiated directly. Use FileSystem.getDirectoryForPath, FileSystem.resolve, or Directory.getContents to create an instance of this class.
Note: Directory.fullPath always has a trailing slash.
See the FileSystem class for more details.
Param | Type | Description |
---|---|---|
fullPath | string | The full path for this Directory. |
fileSystem | FileSystem | The file system associated with this Directory. |
directory.isEmptyAsync() ⇒ Promise.<boolean>
Returns true if is a directory exists and is empty.
Kind: instance method of Directory
Returns: Promise.<boolean>
- True if directory is empty and it exists, else false.
directory.unlinkEmptyDirectoryAsync() ⇒ Promise.<void>
Recursively deletes all empty subdirectories within the current directory. If all subdirectories are empty, the current directory itself will be deleted. A directory is considered empty if it doesn't contain any files in its subtree.
If a subtree contains a large number of nested subdirectories and no files, the whole tree will be deleted. Only branches that contain a file will be retained.
Kind: instance method of Directory
Returns: Promise.<void>
- A Promise that resolves when the operation is finished
Throws:
FileSystemError
If an error occurs while accessing the filesystem
Example
await dir.unlinkEmptyDirectoryAsync();
directory.getContentsAsync(filterNothing) ⇒ Object
Read the contents of a Directory, returns a promise. It filters out all files that are not shown in the file tree by default, unless the filterNothing option is specified.
Kind: instance method of Directory
Returns: Object
- An object
with attributes - entries(an array of file system entries), contentStats and contentsStatsErrors(a map from
content name to error if there is any).
Param | Type | Description |
---|---|---|
filterNothing | boolean | is specified, will return a true contents of dir as shown in disc, weather it is shown in the file tree or not. Can be used for backup/restore flows. |
directory.getContents(callback, filterNothing)
Read the contents of a Directory. It filters out all files that are not shown in the file tree by default, unless the filterNothing option is specified.
Kind: instance method of Directory
Param | Type | Description |
---|---|---|
callback | function | Callback that is passed an error code or the stat-able contents of the directory along with the stats for these entries and a fullPath-to-FileSystemError string map of unstat-able entries and their stat errors. If there are no stat errors then the last parameter shall remain undefined. |
filterNothing | boolean | is specified, will return a true contents of dir as shown in disc, weather it is shown in the file tree or not. Can be used for backup/restore flows. |
directory.createAsync() ⇒ Promise.<FileSystemStats>
Create a directory and returns a promise that will resolve to a stat
Kind: instance method of Directory
Returns: Promise.<FileSystemStats>
- resolves to the stats of the newly created dir.
directory.create([callback])
Create a directory
Kind: instance method of Directory
Param | Type | Description |
---|---|---|
[callback] | function | Callback resolved with a FileSystemError string or the stat object for the created directory. |