You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ripple.apache.org by marco sangiorgi <ma...@neropaco.net> on 2013/03/26 15:05:04 UTC
How to simulate LocalFileSystem on chrome extension (linux)
Hi everybody,
I'm trying to debug a cordova 2.5 app with ripple.
This app makes json requests to a remote server, get some data and save
them in some localFileSystem files.
This is the code deputated to save files:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSystem){
fileSystem.root.getDirectory("mydirectory",
{create:true}, function(dir){
dir.removeRecursively(function(){
fileSystem.root.getDirectory("mydirectory", {create:true, exclusive:
false}, function(){
scarica(data, sync_ok);
});
})
})
})
function scarica(data, callback){
$.each(data, function(index, q){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fs){
fs.root.getFile("mydirectory/"+q.id+".html", {create:true},
function(file){
scriviSuFile(file.name, q.html);
});
})
})
callback();
}
function scriviSuFile(file, data){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSystem){
fileSystem.root.getFile("mydirectory/"+file, {create: true},
function(file){
file.createWriter(function(writer){
writer.write(data)
})
});
});
}
It works quite good on physicals device, but I'm not able to make it works
with ripple emulator. Webkit console returns no errors.
Some ideas?
Thanks in advance,
Marco Sangiorgi