Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.
iPhone / iPod Touch SDK | Development Discussionforums, a part of the
3rd Party Apps For iPhone | iPod Touchsection;
When accessing files via ObjC, is "~" recognized as the user's directory? I suppose if not, I can try the [UIApplication userHomeDirectory] method... does anyone knows if this works like...
02-06-2008, 08:30 PM #1Root or Mobile - letting the program decide?
When accessing files via ObjC, is "~" recognized as the user's directory?
I suppose if not, I can try the [UIApplication userHomeDirectory] method...
does anyone knows if this works like I think it does? (i.e. does it return /private/var/root for firmware versions 1.1.2(-) and /private/var/mobile for firmware versions 1.1.3(+)?
Okay, I've checked it out myself and here the results:
I'm running 1.1.3 -
[[NSString stringWithFormat: @"~/%@", @"Media/Skins"] stringByExpandingTildeInPath] = "/var/root/Media/Skins"
[self userHomeDirectory] = "/var/root" -- i.e. the same effect as calling stringByExpandingTildeInPath on @"~"
I'm not sure how it's root...I guess NateTrue 1.1.3 installation sets it that way...
02-06-2008, 08:32 PM #2
it means the home directory of the user who is running.
it has nothing to do with the version of the iPhone. it has to do with where the app is running. (113 runs as mobile, others run as root)
so under 113 it's user is mobile and ~ means /private/var/mobile
if you want another's home directory try ~root or ~mobile as they are UNIXisms for the home directory of another user!
PS Nate's is wack... code for the dev team standard!
Last edited by jakecigar; 02-06-2008 at 09:36 PM.http://jpassoc.com/x -- with free itunes under the puppy!
If I help you out, please press ★THANKS!
3g QuickPWN'ed with 2.1
02-06-2008, 08:41 PM #3
ditto to what jake posted, except it's OS X-ismWhite 3G
02-06-2008, 09:57 PM #4
But that's not exactly what I was asking...I was asking whether the framworks recognize this. And the answer to this turned out to be: sortof. When I left the tilde in the path, the NSString file-handling methods didn't seem to translate it according to what it should be. But NSString does come with the handy "expand-the-tilde" method that does translate it, so that works. And the UIApplication method works as well.
And that's what I would think, except with my version 1.1.3...it returns root. I'm not sure if I'm running stuff as root or not. I believe the NateTrue version simply puts mobile as a symlink to root...perhaps what happens is that it gets the mobile directory but resolves the symlinks (mobile -> root) before returning the path string (i.e. returning the canonical name). Either way, it works fine...if the user directory resolves to root for either reason, I figure the program will have access to it...
02-07-2008, 08:15 AM #5
Nate's jail break, as you noticed, will return "/var/root/" for ~ due to the symlink
The Dev teams jail break will return "/var/mobile/" for ~
I have been using "stringByExpandingTildeInPath" since firmware 1.1.1 but I know it works in 1.0.2 so I would not say sort of, I'd say it works just fine.White 3G
02-07-2008, 01:32 PM #6
I said sort-of to refer to the fact that the frameworks in general don't translate the tilde--you can't use it (raw) to specify a file/directory, the exception being the tilde expansion method.