これは非常に単純なはずですが、機能させることができません
シナリオ: phonegap ファイル API を使用してフォルダーを繰り返し処理したい
問題: getDirectory() 関数が機能しません
非常に簡単な例: (私の問題を説明するため)
var fileSystem, basePath;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, doStuff, function(error) {
notificationservice.log('Failed to get local filesystem: ' + error.code);
});
function doStuff(fs) {
fileSystem = fs;
basePath = fileSystem.root.fullPath;
var directoryEntry = new DirectoryEntry('', basePath);
readDirectory(directoryEntry);
}
function readDirectory(directoryEntry) {
var directoryReader = directoryEntry.createReader();
directoryReader.readEntries(function(entries) {
for (var i = 0 ; i < entries.length ; i++) {
notificationservice.log(entries[i].fullPath);
fileSystem.root.getDirectory(entries[i].fullPath, {create: false}, function(dir) {
notificationservice.log('SUCCESS');
}, function (error) {
notificationservice.log('Failed to get directory');
});
}
});
}
を使用してフォルダーにアクセスできますがnew DirectoryEntry()
、関数を使用してディレクトリにアクセスしようとすると失敗します。エラーが返されないgetDirectory()
ように上記のコードを修正してくれる人がいれば、とても感謝しています。fileSystem.root.getDirectory()
注意: 私は展開に eclipse エディターを使用し、Nexus 7 に展開します (可能であれば、コードは iOS などのプラットフォームで動作するか、勝利する必要があります)。
ありがとう、マティアス
ところで、この問題を実際に解決する多くの質問があると確信しています - しかし、私のために働くものを見つけることができませんでした...