Hello,
i have a problem with the Cordova FileSystem plugin ( https://github.com/apache/cordova-plugin-file/blob/dev/doc/index.md ).
The problem is, the plugin works asynchronous. Let me show my code.
In my “service.js” i have a factory with returns like:
checkFile: function (fileTyp) {
window.requestFileSystem(window.PERSISTENT, 1024*1024, function(filesystem) {
filesystem.root.getFile('/bpa_json/'+ fileTyp +'.json', {create: false},
function() {
return true;
},
function() {
return false;
}
);
});
},
createFile: function (fileTyp) {
window.requestFileSystem(window.PERSISTENT, 1024*1024, function(filesystem) {
if(filesystem){
filesystem.root.getFile('/bpa_json/'+ fileTyp +'.json', {create: true},
function(fCreateSuccess) {
alert("FILE CREATED");
}
);
}
});
}
I use the factory in my controller like:
if(FileService.checkFile('topnews')) {
alert("FILE EXIST");
} else {
FileService.createFile('topnews');
}
So, the problem is, if i call “FileService.checkFile(‘topnews’)” it will always return undefined because “window.requestFileSystem” is asynchronous and returns before i can look if the file exists “filesystem.root.getFile(” to return the real result.
Hope here is a Cordova FileSystem expert 
A tutorial for FIleSystem usage: http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota