Reputation: 12515
I see that it correctly returns the root directory as a directory when I pass in '/', but can it be used to detect if a file exists? Heck, is there even a file system that is accessible to even get at? Porting some PC code here and wondering if I should just basically assert false on calls like this that assume a file system exists.
Upvotes: 0
Views: 1262
Reputation: 55583
Yes, a file system always exists on iOS, but generally the path you want is "/var/mobile/", as anything outside of 'mobile' is out of your domain to read/write to/from.
Generally, however, you are supposed to write files to your sandboxed application's documents directory, which can be gotten like this:
// this becomes a char *, if you need NSString, then just remove the UTF8String call.
#define HOME_DIRECTORY [[NSSearchPathForDirectoriesInDomains(NSDocumentsDirectory, NSUserDomainMask, YES) objectAtIndex:0] UTF8String]
Upvotes: 2