user1831464
user1831464

Reputation: 43

Phonegap - Read sub-directories?

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

Answers (1)

Simon MacDonald
Simon MacDonald

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

Related Questions