Chris (& all) -
Now that I look at the problem more closely, I see that the local storage is
actually working (I had to reboot the phone just to make sure), but I am
getting error messages - which I originally took to mean that it wasn't.
Here is the code that is failing. The message I'm getting is 'Failed to create
options file: undefined' - that is coming from _errorHandler:
//--save options struct to file
saveOptions = function (_options) {
var
_fileWriter,
_errorHandler = function (_evt) {
alert('Failed to create options file: ' + _evt.name);
},
_getFileSuccess = function (_fileEntry) {
_fileEntry.createWriter(_writeFile, _errorHandler);
},
_onWriteEnd = function () {
_fileWriter.onwriteend = undefined;
if ('undefined' === typeof window.cordova) {
//--for Chrome
_fileWriter.write(new
Blob([JSON.stringify(_options)], {type: 'text/plain'}));
} else {
//--for PhoneGap
_fileWriter.write(JSON.stringify(_options));
}
},
_writeFile = function (_fw) {
_fileWriter = _fw,
_fileWriter.onerror = _errorHandler;
_fileWriter.onwriteend = _onWriteEnd;
_fileWriter.truncate(0);
};
if ('undefined' === typeof dirEntry) {
if ('undefined' !== typeof window.cordova) {
alert('Failed to access file system to save options');
}
return;
}
But, like I said the app is actually saving its current state and picks up
where it left off even after reboot. So it looks like the error handler is
being called promiscuously?
BTW, do you know off-hand how to access local files on the Flame device. I
installed a file manager from the app store which did precisely nothing (just
showed sdcard and external storage as being empty) and remote access from my pc
doesn't achieve much more. On android devices I use ES File Manage just to have
a look at the contents of the saved file.
Regards,
William
-----Original Message-----
From: Chris Mills [mailto:[email protected]]
Sent: 20 October 2014 11:21
To: Piotr Zalewa; William Hudson
Cc: Jason Weathersby; mozilla-dev-b2g; Rodrigo Silveira; Fred Wenzel
Subject: Re: [b2g] Firefox OS support for Cordova File API?
Ah, so we do support the File API - that’s good news.
Any thoughts on William’s specific problem? William, perhaps you could point us
to a code sample so we can see if we can see what’s up with it?
Best,
Chris Mills
Senior tech writer || Mozilla
developer.mozilla.org || MDN
[email protected] || @chrisdavidmills
> On 20 Oct 2014, at 11:19, Piotr Zalewa <[email protected]> wrote:
>
> Hi All,
>
> Right - it needs to be updated
> After first look - file, file-transfer and globalization are missing
> I will contact Chris about it on IRC
>
> Piotr
>
> W dniu 20/10/2014 10:15, Chris Mills pisze:
>> Hi William,
>>
>> I have cc’d Jason and Piotr on this mail, as they know considerably more
>> about the Firefox OS Cordova support than me. Guys, see Williams’s question
>> below - have we landed support for the Cordova File API stuff? According to
>> the documenttion, no:
>>
>> https://developer.mozilla.org/en-US/Apps/Tools_and_frameworks/Cordova_support_for_Firefox_OS
>>
>> But this might be out of date now.
>>
>> I’m happy to update the docs if needed, and also to explore this specific
>> problem.
>>
>> Chris Mills
>> Senior tech writer || Mozilla
>> developer.mozilla.org || MDN
>> [email protected] || @chrisdavidmills
>>
>>
>>
>>> On 17 Oct 2014, at 16:04, [email protected] wrote:
>>>
>>> I have a Cordova app that runs on Android, iOS, Windows Phone and Kindle
>>> Fire. I thought it might be fun to port it to Firefox OS. I've got a Flame
>>> phone and the app now runs, but my calls to the Cordova File APIs, to load
>>> and save options and game status on a semi-regular basis are failing.
>>>
>>> Does anyone know off-hand if the Cordova File APIs are supported? I thought
>>> since I saw that Firefox OS was supported by Cordova, that this stuff would
>>> work. Is it just a question of permissions (the app is packaged and
>>> privileged) or do I need to do this differently altogether?
>>>
>>> Thanks in advance for any pointers!
>>>
>>> Regards,
>>>
>>> William
>>>
>>> PS - the failing calls are to things like window.requestFileSystem and
>>> fileSystem.root.getDirectory.
>>> _______________________________________________
>>> dev-b2g mailing list
>>> [email protected]
>>> https://lists.mozilla.org/listinfo/dev-b2g
>>
>
> --
> Piotr Zalewa
> Mozilla
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g