Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Once you have access to the file system (either through the persistent or temporary storage area), you have the ability to process directory entries using the File API’s DirectoryReader object. To create a DirectoryReader object, an application must make a call to createReader, as shown in the following function:
function onGetFileSystemSuccess(fs) {
alert("Accessing " + fs.name + " storage (" +
fs.root.fullPath + ")");
//Create a directory reader we'll use to list the files in
//the directory
var dr = fs.root.createReader();
// Get a list of all the entries in the directory
dr.readEntries(onDirReaderSuccess, onFileError);
}
In this example, the call to createReader is made in the callback function executed after requesting a file system object as described in the previous section. Here the application uses the file system object to create a DirectoryReader pointing at the root folder of the selected file system. The DirectoryReader (dr in the example) supports only a single method, readEntries, which is used to read all of the entries in the specified folder.