orxConfig_Save and iOS?

edited April 2014 in Help request
I'm finishing up Ski Hard for iOS and there is one thing left for me to get working. I am currently using orxConfig_Save to save settings - it's working on PC and Android, but I'm seeing error messages in the logs on iOS ("can't open file" or something similar).
orxBOOL useEncryption = orxTRUE;
orxConfig_Save("save.ini", useEncryption, SaveConfigFilter);


I have a feeling I'm trying to write to the read-only resources directory or something like that (?), but being new to iOS I don't really know enough about what I should be doing, so I have a vague feeling that I am missing something obvious.

Question: Should I expect orxConfig_Save to just work "out of the box" on iOS, or do I need to do something special?

Comments

  • edited April 2014
    Hi!

    orxConfig_Save() behaves the same way on all platforms, ie. all the paths are relative to the executable's folder by default (unless you've called chdir manually, of course).

    In the case of iOS, that directory isn't writable, as you've noticed.
    I don't know if the directory hierarchy has changed since iOS 4.x, but the writable directory used to be at ../Documents (case-sensitive).

    If you're using the thread branch of orx, I recently added orxFile_GetHomeDirectory() & orxFile_GetApplicationSaveDirectory() that will make it pretty easy to always save your file where users expect them to be. :)
    Those functions will also construct the full usable path if you give them the actual destination, more info about this here.

    Lemme know if you have any issues.
  • edited April 2014
    Cheers iarwain, that makes sense. I was just about to write here that I got it working with explicitly getting the Documents path using something similar to this:

    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    I don't think I actually tried ../Documents but I suspect that might work. I did try /Documents because I read somewhere that apps are tricked into thinking they're running in the root directory, but not sure if that's actually the case.

    Using your new functions sound like a neater solution though so I'll definitely check them out - thanks again!
  • edited April 2014
    actually on Android, i'm forcing a chdir to the internal application private folder during the init of orx.

    There are two effects for this,
    1) you don't have to specify this folder when using orxConfig_Save()
    2) this private folder act as an overlay of the /assets folder in the apk. since files are first tried to be opened in there before the apk files.
Sign In or Register to comment.