Search code examples
iphonecocoa-touchiosjailbreak

Access user home folder outside sandbox


I'm working on a app which will not be submitted to the AppStore and am trying to open a file which the user has downloaded using Safari Download Manager.

This plugin mentions all files are downloaded inside ~/Media/Downloads.

I've tried just using NSString's stringByExpandingTildeInPath, but it will map to /Media/Downloads inside the application sandbox.

Question is: how can I tilde-expand that path so it maps to the actual folder?

Thanks!


Solution

  • I assume that by "Safari Download Manager" you mean that you already have a jailbroken phone. If so, the easiest way is to just install something like iFile and find out what the path is.

    I'm assuming that it's something like /var/mobile/Media/Downloads. Then, there are two easy things you can do:

    • Hard-code "/var/mobile" to expand a tilde at the beginning of the string.
    • Find out the username you want the homedir for (probably "mobile") and try expanding ~mobile/Media/Downloads.
    • Find the username, and get the homedir with a call to getpwnam() or so (assuming it exists on iOS).