Reputation: 43
I am working with Phonegap / Cordova 2.2
I am trying to read the contents of a sub-directory but can not figure out how to do it.
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 only fetch a single directory path then it works, if I try to fetch a path with two directories it fails.
Any help would be appreciated.
Thanks
Upvotes: 4
Views: 2924
Reputation: 23273
Well 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 didn't work. What platform are you testing on?
Upvotes: 5