I'm trying to make a dynamic interface for interacting with the HTML5 filesystem in Chrome Canary, but I am currently hitting a stumbling block.
I use
dirReader.readEntries(function (entries) {
if (!entries.length){
return;
}
for (var i = 0 ; i < entries.length; i++){
$scope.files.push(entries[i]);
}
dirReader.readEntries();
}, errorHandler);
to get them the first time, which works fine. But if I create a new file, and run the code again, it returns nothing.
I imagine it is using an old reference to the file system or something like that, so I imagine I need to reinitialize the file system or the directory reader (That's a guess)? What is the best way to deal with that issue?
Edit: Getting a new reference to the file system does work, but that makes me vomit a little. A better way to do that would still be excellent.
The excellent HTML5rocks website for file handling
To read the contents of a directory, create a DirectoryReader and call its readEntries() method. There is no guarantee that all of a directory's entries will be returned in a single call to readEntries(). That means you need to keep calling DirectoryReader.readEntries() until no more results are returned.
I read that to mean that a DirectoryReader
is a one off object. Once you have read it you will get no more data from it. So instead of getting a new file system reference try creating a new DirectoryReader
.