Interface DirectoryEntry

This interface represents a directory on a file system.

Hierarchy

Index

Properties

Methods

Properties

public fileSystem: FileSystem

The file system on which the entry resides.

public fullPath: string

The full absolute path from the root to the entry.

public isDirectory: boolean

Entry is a directory.

public isFile: boolean

Entry is a file.

public name: string

The name of the entry, excluding the path leading to it.

public nativeURL: string

Methods

public copyTo(parent: DirectoryEntry, newName?: string, successCallback?: (entry: Entry) => void, errorCallback?: (error: Error) => void)

Copy an entry to a different location on the file system. It is an error to try to: copy a directory inside itself or to any child at any depth; copy an entry into its parent if a name different from its current one isn't provided; copy a file to a path occupied by a directory; copy a directory to a path occupied by a file; copy any element to a path occupied by a directory which is not empty. A copy of a file on top of an existing file must attempt to delete and replace that file. A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory. Directory copies are always recursive--that is, they copy all contents of the directory.

Parameters

  • parent: DirectoryEntry

    The directory to which to move the entry.

  • newName?: string optional

    The new name of the entry. Defaults to the Entry's current name if unspecified.

  • successCallback?: (entry: Entry) => void optional

    A callback that is called with the Entry for the new object.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public createReader(): DirectoryReader

Creates a new DirectoryReader to read Entries from this Directory.

Returns

DirectoryReader

public getDirectory(path: string, options?: Flags, successCallback?: (entry: DirectoryEntry) => void, errorCallback?: (error: Error) => void)

Creates or looks up a directory.

Parameters

  • path: string

    Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist.

  • options?: Flags optional

    If create and exclusive are both true and the path already exists, getDirectory must fail. If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry. If create is not true and the path doesn't exist, getDirectory must fail. If create is not true and the path exists, but is a file, getDirectory must fail. Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.

  • successCallback?: (entry: DirectoryEntry) => void optional

    A callback that is called to return the Directory selected or created.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public getFile(path: string, options?: Flags, successCallback?: (entry: FileEntry) => void, errorCallback?: (error: Error) => void)

Creates or looks up a file.

Parameters

  • path: string

    Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist.

  • options?: Flags optional

    If create and exclusive are both true, and the path already exists, getFile must fail. If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry. If create is not true and the path doesn't exist, getFile must fail. If create is not true and the path exists, but is a directory, getFile must fail. Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.

  • successCallback?: (entry: FileEntry) => void optional

    A callback that is called to return the File selected or created.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public getMetadata(successCallback: (metadata: Metadata) => void, errorCallback?: (error: Error) => void)

Look up metadata about this entry.

Parameters

  • successCallback: (metadata: Metadata) => void

    A callback that is called with the time of the last modification.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public getParent(successCallback: (entry: Entry) => void, errorCallback?: (error: Error) => void)

Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself.

Parameters

  • successCallback: (entry: Entry) => void

    A callback that is called with the time of the last modification.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public moveTo(parent: DirectoryEntry, newName?: string, successCallback?: (entry: Entry) => void, errorCallback?: (error: Error) => void)

Move an entry to a different location on the file system. It is an error to try to: move a directory inside itself or to any child at any depth;move an entry into its parent if a name different from its current one isn't provided; move a file to a path occupied by a directory; move a directory to a path occupied by a file; move any element to a path occupied by a directory which is not empty. A move of a file on top of an existing file must attempt to delete and replace that file. A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.

Parameters

  • parent: DirectoryEntry

    The directory to which to move the entry.

  • newName?: string optional

    The new name of the entry. Defaults to the Entry's current name if unspecified.

  • successCallback?: (entry: Entry) => void optional

    A callback that is called with the Entry for the new location.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public remove(successCallback: () => void, errorCallback?: (error: Error) => void)

Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem.

Parameters

  • successCallback: () => void

    A callback that is called on success.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public removeRecursively(successCallback: () => void, errorCallback?: (error: Error) => void)

Deletes a directory and all of its contents, if any. In the event of an error (e.g. trying to delete a directory that contains a file that cannot be removed), some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.

Parameters

  • successCallback: () => void

    A callback that is called on success.

  • errorCallback?: (error: Error) => void optional

    A callback that is called when errors happen.

public toURL(): string

Returns

string