With regards to the way the iOS file system is laid out, where is the openframeworks /data path located in it? I have an app that needs to use the file transfer feature of iTunes, and I was wondering where exactly the data folder gets plopped when transferred to an iPhone.
In addition, I am having trouble figuring out how to direct the Openframeworks root to the app (user) documents folder on the iPhone. I’ve used:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; char *dirstring; dirstring = [documentsDirectory UTF8String]; ofSetDataPathRoot(dirstring);
as an attempt to read the iPhone’s documents directory constant into a standard string for me to work with. This is clearly wrong, as the types don’t match up, but Apple insists on NSString, which I haven’t successfully been able to convert to a standard string. How do I properly perform this operation?
Aha! Solved it.
I dunno if this is documented elsewhere, but I’ll explain how I did it anyway, in case someone else has the same issue.
So, I use the following code to get a plain string of the iPhone documents directory:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; const char* dirString = [documentsDirectory cStringUsingEncoding:NSASCIIStringEncoding];
And the value dirString can be used to get to /var/mobile/Applications/WHATEVER-YOUR-APP-ID-IS/Documents/. I used ofDisableDataPath() and stuck it into ofxDirList:
And it does successfully list the contents of the App’s documents folder. So now the App has an iTunes-modifiable folder that can be read in OF.