Hi Hugh, ----- Original Message ----- > From: "Hugh Tay" <[email protected]> > To: [email protected] > Sent: Sunday, January 26, 2014 7:58:18 AM > Subject: Re: [b2g] Trouble accessing the SD card from the Emulator build > > Hi Dave, > > > I've finally managed to get the DeviceStorage functionality to work within my > App. Thank you so much for suggesting the troubleshooting methods I could > try (no pun intended). =) > > Maybe in my case the problem was caused by implementing LocalStorage code > together with DeviceStorage code; I separated the code piece by piece and > was able to read from/write to the SD-card eventually. > > --- > > Anyhow, I have 2 other questions I would like to consult you about... > > > The 1st is that per this Bugzilla thread - > https://bugzilla.mozilla.org/show_bug.cgi?id=859696 - is deleting and > re-creating a file really the only way to save changes to the file right > now?
yes - There is are 2 bugs which are relevant. The first is that the editable variation of get hasn't been implemented for OOP (Out-Of-Process) apps (and all apps on FxOS are OOP). Bug 771288 - Multiprocess FileHandle support Bug 859696 - [DeviceStorage] getEditable's result is not FileHandle object. Diff with spec. And there is some work for this bug Bug 910412 - Change DeviceStorage API to use FileSystem API spec which may make things easier once it lands. > The 2nd is if I need to read multiple files synchronously; would that be > possible? > > You see the trouble is, my App requires info from various files and it can't > do anything else 'in the meantime' while waiting for the info, so the > asynchronous method doesn't really help in this case as now I would have to > hook up lots of listeners to notify me when the process is complete. > > Are there perhaps alternative approaches I could consider? The API is inherently asynchronous, so you can either issue all of your requests at once and use a queue to keep track of whether they're all done or not, or you can read a file, wait for the read to complete, perform the next operation, etc. ds-test does the process one file at a time approach. http://dxr.mozilla.org/mozilla-central/source/dom/devicestorage/test/test_lastModificationFilter.html is an example of another program which adds six files, one after the other, with a delay added between the first 3 and last 3 files. It starts at addOldFiles which calls addFileArray to add some files, and then does a delay and calls addFileArray to add some more files. Dave Hylands _______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
