Dart API Referencedart:htmlDirectoryEntry

DirectoryEntry class

DRAFT
This page is not complete.

The DirectoryEntry interface of the FileSystem API represents a directory in a file system.

@DomName('DirectoryEntry')
class DirectoryEntry extends Entry native "DirectoryEntry" {
 
 /**
  * Create a new directory with the specified `path`. If `exclusive` is true,
  * the returned Future will complete with an error if a directory already
  * exists with the specified `path`.
  */
 Future<Entry> createDirectory(String path, {bool exclusive: false}) {
   return _getDirectory(path, options: 
       {'create': true, 'exclusive': exclusive});
 }

 /**
  * Retrieve an already existing directory entry. The returned future will
  * result in an error if a directory at `path` does not exist or if the item
  * at `path` is not a directory.
  */
 Future<Entry> getDirectory(String path) {
   return _getDirectory(path);
 }

 /**
  * Create a new file with the specified `path`. If `exclusive` is true,
  * the returned Future will complete with an error if a file already
  * exists at the specified `path`.
  */
 Future<Entry> createFile(String path, {bool exclusive: false}) {
   return _getFile(path, options: {'create': true, 'exclusive': exclusive});
 }
 
 /**
  * Retrieve an already existing file entry. The returned future will
  * result in an error if a file at `path` does not exist or if the item at
  * `path` is not a file.
  */
 Future<Entry> getFile(String path) {
   return _getFile(path);
 }

 @DomName('DirectoryEntry.createReader')
 @DocsEditable
 DirectoryReader createReader() native;

 @DomName('DirectoryEntry.getDirectory')
 @DocsEditable
 void __getDirectory(String path, {Map options, _EntryCallback successCallback, _ErrorCallback errorCallback}) {
   if (?errorCallback) {
     var options_1 = convertDartToNative_Dictionary(options);
     ___getDirectory_1(path, options_1, successCallback, errorCallback);
     return;
   }
   if (?successCallback) {
     var options_2 = convertDartToNative_Dictionary(options);
     ___getDirectory_2(path, options_2, successCallback);
     return;
   }
   if (?options) {
     var options_3 = convertDartToNative_Dictionary(options);
     ___getDirectory_3(path, options_3);
     return;
   }
   ___getDirectory_4(path);
   return;
 }
 @JSName('getDirectory')
 @DomName('DirectoryEntry.getDirectory')
 @DocsEditable
 void ___getDirectory_1(path, options, _EntryCallback successCallback, _ErrorCallback errorCallback) native;
 @JSName('getDirectory')
 @DomName('DirectoryEntry.getDirectory')
 @DocsEditable
 void ___getDirectory_2(path, options, _EntryCallback successCallback) native;
 @JSName('getDirectory')
 @DomName('DirectoryEntry.getDirectory')
 @DocsEditable
 void ___getDirectory_3(path, options) native;
 @JSName('getDirectory')
 @DomName('DirectoryEntry.getDirectory')
 @DocsEditable
 void ___getDirectory_4(path) native;

 @JSName('getDirectory')
 @DomName('DirectoryEntry.getDirectory')
 @DocsEditable
 Future<Entry> _getDirectory(String path, {Map options}) {
   var completer = new Completer<Entry>();
   __getDirectory(path, options : options,
       successCallback : (value) { completer.complete(value); },
       errorCallback : (error) { completer.completeError(error); });
   return completer.future;
 }

 @DomName('DirectoryEntry.getFile')
 @DocsEditable
 void __getFile(String path, {Map options, _EntryCallback successCallback, _ErrorCallback errorCallback}) {
   if (?errorCallback) {
     var options_1 = convertDartToNative_Dictionary(options);
     ___getFile_1(path, options_1, successCallback, errorCallback);
     return;
   }
   if (?successCallback) {
     var options_2 = convertDartToNative_Dictionary(options);
     ___getFile_2(path, options_2, successCallback);
     return;
   }
   if (?options) {
     var options_3 = convertDartToNative_Dictionary(options);
     ___getFile_3(path, options_3);
     return;
   }
   ___getFile_4(path);
   return;
 }
 @JSName('getFile')
 @DomName('DirectoryEntry.getFile')
 @DocsEditable
 void ___getFile_1(path, options, _EntryCallback successCallback, _ErrorCallback errorCallback) native;
 @JSName('getFile')
 @DomName('DirectoryEntry.getFile')
 @DocsEditable
 void ___getFile_2(path, options, _EntryCallback successCallback) native;
 @JSName('getFile')
 @DomName('DirectoryEntry.getFile')
 @DocsEditable
 void ___getFile_3(path, options) native;
 @JSName('getFile')
 @DomName('DirectoryEntry.getFile')
 @DocsEditable
 void ___getFile_4(path) native;

 @JSName('getFile')
 @DomName('DirectoryEntry.getFile')
 @DocsEditable
 Future<Entry> _getFile(String path, {Map options}) {
   var completer = new Completer<Entry>();
   __getFile(path, options : options,
       successCallback : (value) { completer.complete(value); },
       errorCallback : (error) { completer.completeError(error); });
   return completer.future;
 }

 @JSName('removeRecursively')
 @DomName('DirectoryEntry.removeRecursively')
 @DocsEditable
 void _removeRecursively(VoidCallback successCallback, [_ErrorCallback errorCallback]) native;

 @JSName('removeRecursively')
 @DomName('DirectoryEntry.removeRecursively')
 @DocsEditable
 Future removeRecursively() {
   var completer = new Completer();
   _removeRecursively(
       () { completer.complete(); },
       (error) { completer.completeError(error); });
   return completer.future;
 }

}

Extends

Interceptor > Entry > DirectoryEntry

Properties

final FileSystem filesystem #

inherited from Entry
The file system on which the entry resides.
final FileSystem filesystem

final String fullPath #

inherited from Entry
final String fullPath

final int hashCode #

inherited from Interceptor

Get a hash code for this object.

All objects have hash codes. Hash codes are guaranteed to be the same for objects that are equal when compared using the equality operator ==. Other than that there are no guarantees about the hash codes. They will not be consistent between runs and there are no distribution guarantees.

If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.

docs inherited from Object
int get hashCode => Primitives.objectHashCode(this);

final bool isDirectory #

inherited from Entry
The entry is a directory.
final bool isDirectory

final bool isFile #

inherited from Entry
The entry is a file.
final bool isFile

final String name #

inherited from Entry
The name of the entry, excluding the path leading to it.
final String name

final Type runtimeType #

inherited from Interceptor

A representation of the runtime type of the object.

docs inherited from Object
Type get runtimeType => getRuntimeType(this);

Operators

bool operator ==(other) #

inherited from Interceptor

The equality operator.

The default behavior for all Objects is to return true if and only if this and other are the same object.

If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.

docs inherited from Object
bool operator ==(other) => identical(this, other);

Methods

Future<Entry> copyTo(DirectoryEntry parent, {String name}) #

inherited from Entry

Copy an entry to a different location on the file system. You cannot copy an entry inside itself if it is a directory nor can you copy it into its parent if a name different from its current one isn't provided. Directory copies are always recursive—that is, they copy all contents of the directory.

void vopyTo (
  (in DirectoryEntry parent, optional DOMString newName, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
);
Parameter
parent
The directory to which to move the entry.
newName
The new name of the entry. Defaults to the entry's current name if unspecified.
successCallback
A callback that is called with the entry for the new object.
errorCallback
A callback that is called when errors happen.
Returns
void
@JSName('copyTo')
@DomName('Entry.copyTo')
@DocsEditable
Future<Entry> copyTo(DirectoryEntry parent, {String name}) {
 var completer = new Completer<Entry>();
 _copyTo(parent, name : name,
     successCallback : (value) { completer.complete(value); },
     errorCallback : (error) { completer.completeError(error); });
 return completer.future;
}

Future<Entry> createDirectory(String path, {bool exclusive: false}) #

Create a new directory with the specified path. If exclusive is true, the returned Future will complete with an error if a directory already exists with the specified path.

Future<Entry> createDirectory(String path, {bool exclusive: false}) {
 return _getDirectory(path, options: 
     {'create': true, 'exclusive': exclusive});
}

Future<Entry> createFile(String path, {bool exclusive: false}) #

Create a new file with the specified path. If exclusive is true, the returned Future will complete with an error if a file already exists at the specified path.

Future<Entry> createFile(String path, {bool exclusive: false}) {
 return _getFile(path, options: {'create': true, 'exclusive': exclusive});
}

DirectoryReader createReader() #

Creates a new DirectoryReader to read entries from this Directory.

void getMetada ();
Returns
DirectoryReader
@DomName('DirectoryEntry.createReader')
@DocsEditable
DirectoryReader createReader() native;

Future<Entry> getDirectory(String path) #

Retrieve an already existing directory entry. The returned future will result in an error if a directory at path does not exist or if the item at path is not a directory.

Future<Entry> getDirectory(String path) {
 return _getDirectory(path);
}

Future<Entry> getFile(String path) #

Retrieve an already existing file entry. The returned future will result in an error if a file at path does not exist or if the item at path is not a file.

Future<Entry> getFile(String path) {
 return _getFile(path);
}

Future<Metadata> getMetadata() #

inherited from Entry

Look up metadata about this entry.

void getMetada (
  in MetadataCallback ErrorCallback
);
Parameter
successCallback
A callback that is called with the time of the last modification.
errorCallback
A callback that is called when errors happen.
Returns
void
@JSName('getMetadata')
@DomName('Entry.getMetadata')
@DocsEditable
Future<Metadata> getMetadata() {
 var completer = new Completer<Metadata>();
 _getMetadata(
     (value) { completer.complete(value); },
     (error) { completer.completeError(error); });
 return completer.future;
}

Future<Entry> getParent() #

inherited from Entry

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

void getParent (
  (in EntryCallback successCallback, optional ErrorCallback errorCallback);
);
Parameter
parent
The directory to which to move the entry.
newName
The new name of the entry. Defaults to the entry's current name if unspecified.
successCellback
A callback that is called with the entry for the new object.
errorCallback
A callback that is called when errors happen.
Returns
void
@JSName('getParent')
@DomName('Entry.getParent')
@DocsEditable
Future<Entry> getParent() {
 var completer = new Completer<Entry>();
 _getParent(
     (value) { completer.complete(value); },
     (error) { completer.completeError(error); });
 return completer.future;
}

Future<Entry> moveTo(DirectoryEntry parent, {String name}) #

inherited from Entry

Move an entry to a different location on the file system. You cannot do the following:

  • 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.

Moving a file over an existing file replaces that existing file. A move of a directory on top of an existing empty directory replaces that directory.

void moveTo (
  (in DirectoryEntry parent, optional DOMString newName, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
);
Parameter
parent
The directory to which to move the entry.
newName
The new name of the entry. Defaults to the entry's current name if unspecified.
successCallback
A callback that is called with the entry for the new object.
errorCallback
A callback that is called when errors happen.
Returns
void
@JSName('moveTo')
@DomName('Entry.moveTo')
@DocsEditable
Future<Entry> moveTo(DirectoryEntry parent, {String name}) {
 var completer = new Completer<Entry>();
 _moveTo(parent, name : name,
     successCallback : (value) { completer.complete(value); },
     errorCallback : (error) { completer.completeError(error); });
 return completer.future;
}

dynamic noSuchMethod(Invocation invocation) #

inherited from Interceptor

noSuchMethod is invoked when users invoke a non-existant method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod in an Invocation. If noSuchMethod returns a value, that value becomes the result of the original invocation.

The default behavior of noSuchMethod is to throw a noSuchMethodError.

docs inherited from Object
dynamic noSuchMethod(Invocation invocation) {
 throw new NoSuchMethodError(
     this,
     _symbolToString(invocation.memberName),
     invocation.positionalArguments,
     _symbolMapToStringMap(invocation.namedArguments));
}

Future remove() #

inherited from Entry

Deletes a file or directory. You cannot delete an empty directory or the root directory of a filesystem.

void remove (
  (in VoidCallback successCallback, optional ErrorCallback errorCallback);
);
Parameter
successCallback
A callback that is called with the entry for the new object.
errorCallback
A callback that is called when errors happen.
Returns
void
@JSName('remove')
@DomName('Entry.remove')
@DocsEditable
Future remove() {
 var completer = new Completer();
 _remove(
     () { completer.complete(); },
     (error) { completer.completeError(error); });
 return completer.future;
}

Future removeRecursively() #

Deletes a directory and all of its contents, if any. If you are deleting a directory that contains a file that cannot be removed, some of the contents of the directory might be deleted. You cannot delete the root directory of a file system.

DOMString toURL (
  (in VoidCallback successCallback, optional ErrorCallback errorCallback);
);
Parameter
successCallback
A callback that is called to return the DirectoryEntry selected or created.
errorCallback
A callback that is called when errors happen.
Returns
void
@JSName('removeRecursively')
@DomName('DirectoryEntry.removeRecursively')
@DocsEditable
Future removeRecursively() {
 var completer = new Completer();
 _removeRecursively(
     () { completer.complete(); },
     (error) { completer.completeError(error); });
 return completer.future;
}

String toString() #

inherited from Interceptor

Returns a string representation of this object.

docs inherited from Object
String toString() => Primitives.objectToString(this);

String toUrl() #

inherited from Entry

Returns a URL that can be used to identify this entry. It has no specific expiration. Bcause it describes a location on disk, it is valid for as long as that location exists. Users can supply mimeType to simulate the optional mime-type header associated with HTTP downloads.

DOMString toURL (
  (in optional DOMString mimeType);
);
Parameter
mimeType
For a FileEntry, the mime type to be used to interpret the file, when loaded through this URL.
Returns
DOMString
@JSName('toURL')
@DomName('Entry.toURL')
@DocsEditable
String toUrl() native;

This page includes content from the Mozilla Foundation that is graciously licensed under a Creative Commons: Attribution-Sharealike license. Mozilla has no other association with Dart or dartlang.org. We encourage you to improve the web by contributing to The Mozilla Developer Network.