Phonegap - read subdirectories?

I work with Phonegap / Cordova 2.2

I am trying to read the contents of a subdirectory but cannot figure out how to do this.

Here is my code:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail); function onFileSystemSuccess(fileSystem) { var tmpPath = "dir1/dir2/"; fileSystem.root.getDirectory(tmpPath, {create: false, exclusive: false}, getDirSuccess, fail); } function getDirSuccess(dirEntry) { // Get a directory reader var directoryReader = dirEntry.createReader(); // Get a list of all the entries in the directory directoryReader.readEntries(readerSuccess,fail); } 

If I get only one directory path, then it works, if I try to get a path with two directories, it fails.

Any help would be greatly appreciated.

thanks

+4
source share
1 answer

Ok, you could do it like this:

 function onFileSystemSuccess(fileSystem) { var tmpPath = filesystem.root.fullPath + "/dir1/dir2"; window.resolveLocalFileSystemURI(tmpPath, getDirSuccess, fail); } 

But I'm curious why the code you showed did not work. What platform are you testing on?

+5
source

All Articles