DirectoryReader

An object that lists files and directories within a directory, as defined in the W3C Directories and Systems specification.

Methods

  • readEntries: Read the entries in a directory.

Supported Platforms

  • Amazon Fire OS
  • Android
  • BlackBerry WebWorks 5.0+
  • iOS
  • Windows Phone 7 and 8
  • Windows 8

readEntries

Read the entries in this directory.

Parameters:

  • successCallback: A callback that is passed an array of [FileEntry](../fileentry/fileentry.html) and [DirectoryEntry](../directoryentry/directoryentry.html) objects. (Function)

  • errorCallback: A callback that executes if an error occurs when retrieving the directory listing. Invoked with a [FileError](../fileerror/fileerror.html) object. (Function)

Quick Example

function success(entries) {
    var i;
    for (i=0; i<entries.length; i++) {
        console.log(entries[i].name);
    }
}

function fail(error) {
    alert("Failed to list directory contents: " + error.code);
}

// Get a directory reader
var directoryReader = dirEntry.createReader();

// Get a list of all the entries in the directory
directoryReader.readEntries(success,fail);