Skip to main content

FileSystemEntry

Import :

const FileSystemEntry = brackets.getModule("filesystem/FileSystemEntry")

FileSystemEntry

Kind: global class

new FileSystemEntry(path, fileSystem)

Model for a file system entry. This is the base class for File and Directory, and is never used directly.

See the File, Directory, and FileSystem classes for more details.

ParamTypeDescription
pathstringThe path for this entry.
fileSystemFileSystemThe file system associated with this entry.

fileSystemEntry.toString()

Helpful toString for debugging purposes

Kind: instance method of FileSystemEntry

fileSystemEntry.exists(callback)

Check to see if the entry exists on disk. Note that there will NOT be an error returned if the file does not exist on the disk; in that case the error parameter will be null and the boolean will be false. The error parameter will only be truthy when an unexpected error was encountered during the test, in which case the state of the entry should be considered unknown.

Kind: instance method of FileSystemEntry

ParamTypeDescription
callbackfunctionCallback with a FileSystemError string or a boolean indicating whether or not the file exists.

fileSystemEntry.existsAsync()

Async version of exists API. Returns true or false if the entry exists. or error rejects.

Kind: instance method of FileSystemEntry

fileSystemEntry.stat(callback)

Returns the stats for the entry.

Kind: instance method of FileSystemEntry

ParamTypeDescription
callbackfunctionCallback with a FileSystemError string or FileSystemStats object.

fileSystemEntry.statAsync() ⇒ Promise.<FileSystemStats>

Returns a promise that resolves to the stats for the entry.

Kind: instance method of FileSystemEntry

fileSystemEntry.rename(newFullPath, [callback])

Rename this entry.

Kind: instance method of FileSystemEntry

ParamTypeDescription
newFullPathstringNew path & name for this entry.
[callback]functionCallback with a single FileSystemError string parameter.

fileSystemEntry.unlinkAsync() ⇒ Promise.<void>

Permanently deletes this entry. For directories, this will delete the directory and all of its contents. For a reversible delete, see moveToTrash().

Kind: instance method of FileSystemEntry
Returns: Promise.<void> - A promise that resolves when the delete is successful or rejects with an error.

fileSystemEntry.unlink([callback])

Permanently delete this entry. For Directories, this will delete the directory and all of its contents. For reversible delete, see moveToTrash().

Kind: instance method of FileSystemEntry

ParamTypeDescription
[callback]functionCallback with a single FileSystemError string parameter.

fileSystemEntry.moveToTrash([callback])

Move this entry to the trash. If the underlying file system doesn't support move to trash, the item is permanently deleted.

Kind: instance method of FileSystemEntry

ParamTypeDescription
[callback]functionCallback with a single FileSystemError string parameter.

fileSystemEntry.visit(visitor, [options], [callback])

Visit this entry and its descendents with the supplied visitor function. Correctly handles symbolic link cycles and options can be provided to limit search depth and total number of entries visited. No particular traversal order is guaranteed; instead of relying on such an order, it is preferable to use the visit function to build a list of visited entries, sort those entries as desired, and then process them. Whenever possible, deep filesystem traversals should use this method. Will not visit all files/dirs that are not shown in the file tree by default, unless the visitHiddenTree option is specified.

Kind: instance method of FileSystemEntry

ParamTypeDescription
visitorfunctionA visitor function (can be async), which is applied to this entry and all descendent FileSystemEntry objects. It can have two args, the first one is the entry being visited, the second is an array of sibling entries that share the same parent dir as the given entry. If the function returns false (or promise that resolved to false)for a particular Directory entry, that directory's descendents will not be visited.
[options]Object
[callback]functionCallback with single FileSystemError string parameter.