+ Reply
Results 1 to 6 of 6

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Root or Mobile - letting the program decide?

is a discussion within the

iPhone / iPod Touch SDK | Development Discussion

forums, a part of the

3rd Party Apps For iPhone | iPod Touch

section;
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
...
  1. #1
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    Default Root 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(+)?

    Thanks,
    JLA

    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...

  2. #2
    iPhoneaholic jakecigar's Avatar
    Join Date
    Aug 2007
    Location
    San Francisco, CA
    Posts
    476
    Thanks
    24
    Thanked 112 Times in 94 Posts

    Quote Originally Posted by JLA View Post
    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(+)?

    Thanks,
    JLA

    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...
    ~ is a UNIXism, therefore an OS X-ism. (OOPS)
    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 08: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

  3. #3
    Retired Moderator CyberGreg's Avatar
    Join Date
    Jul 2007
    Posts
    1,096
    Thanks
    58
    Thanked 207 Times in 138 Posts

    ditto to what jake posted, except it's OS X-ism
    White 3G

  4. #4
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    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.

    Quote Originally Posted by jakecigar View Post
    it has nothing to do with the version of the iPhone. it has to do with where the app is running.
    It does have to do with the version of the firmware...like you said, 1.1.3 is mobile, etc.
    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...

    Thanks,
    JLA

  5. #5
    Retired Moderator CyberGreg's Avatar
    Join Date
    Jul 2007
    Posts
    1,096
    Thanks
    58
    Thanked 207 Times in 138 Posts

    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

  6. #6
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    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.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts