0

I'm wondering if there's any way to change PhoneGap's fileSystem object?

I'm currently using Web Marmalade (which includes a modified PhoneGap in it) and window.requestFileSystem(LocalFileSystem.PERSISTENT...) returns "wm", rather than something like "/mnt/sdcard" on my Android phone. This causes problems because I can't write to /mnt/sdcard - there will be a security error, most probably because /mnt/sdcard is not part of the root filesystem "wm".

So I'm just wondering if there's an easy way to change this fileSystem? I tried something like:

var root = new DirectoryEntry('myroot', '/mnt/sdcard');
var fileSystem = new FileSystem('myfs', root);

But that doesn't seem to help:

alert('fileSystem.root.fullPath: ' + fileSystem.root.fullPath);  //returns ""
chaindriver
  • 882
  • 3
  • 7
  • 15

1 Answers1

1

You can just do:

var myRoot = null;
function myRoot() {
    window.resolveLocalFileSystemURI("/mnt/sdcard", function(dirEntry) {
      myRoot = dirEntry;
    });
}

to get a DirectoryEntry object that represents /mnt/sdcard and do you File API operations off of it.

Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74
  • Thanks for the reply Simon. I've tried it and got the security error (FileError.SECURITY_ERR) that I was talking about... – chaindriver Aug 20 '12 at 15:28
  • Did you make sure you added the write external storage permission to your AndroidManifest.xml? Also, I have no idea what Web Marmalade is. – Simon MacDonald Aug 20 '12 at 16:25
  • Yes the permission has been added during the test. I think this problem is specific to Web Marmalade. Marmalade is a cross-platform C++ app engine, and Web Marmalade is the version that integrates a modified version of PhoneGap in it for HTML5/JS/CSS3 development. Thanks for the replies though, Simon! I see your replies in a lot of other PhoneGap questions, that's very helpful. – chaindriver Aug 21 '12 at 15:18