Getting the Mac "working folder"

Discussion in 'Game Development (Technical)' started by Raptisoft, Jul 27, 2011.

  1. Raptisoft

    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    Hi all,
    On Windows, I have some code that finds me a place to put my game data (like in "C:\Users\[username]\Saved Games" for Vista+).

    What's the equivalent "sandbox" place to put game data on a Mac? Is there one?

    Thanks!
     
  2. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    User Folder > Library > Application Support > Create a Folder Here!

    I think that ejeje is what I used, can sent you some snippets of source when I get to office in morning.
     
  3. Raptisoft

    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    Ah, so there's not some API call to get it or something? I always worry about hard-coding it, because, like, in Windows, I have a branching thing (Are you Win95? Then put it here. WinXP? Put it here. Vista? Put it here), and I wanted to avoid ever having to do that in the future with OSX.
     
  4. Gary Preston

    Original Member

    Joined:
    Aug 5, 2005
    Messages:
    239
    Likes Received:
    0
    My guess would be

    ~/Library/Application Support/<company_name>/<game_name>/Saved Games/

    But it's probably worth trawling the osx docs just in case there's a recommended location. There should be an API call you can use to get the application support directory path (see NSSearchPathForDirectoriesInDomains)
     
  5. richtaur

    Indie Author

    Joined:
    Apr 19, 2009
    Messages:
    262
    Likes Received:
    0
    My game (called Onslaught! Arena) was rejected when I tried to use the same save folder as Safari, but was accepted when I changed it to ~/Library/OnslaughtArena
     
  6. Musenik

    Original Member

    Joined:
    Dec 5, 2004
    Messages:
    796
    Likes Received:
    0
    What he said. That's all.
     
  7. jcottier

    jcottier New Member

    Joined:
    Jul 12, 2006
    Messages:
    1,385
    Likes Received:
    0
    If you wan to save user data... call this:

    NSArray *paths = NSSearchPathForDirectoriesInDomains( NSApplicationSupportDirectory, NSUserDomainMask,YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    then you need to append the name of the folder for your game. If you want to publish with the Mac app store you must use:
    * The exact same name of your App (Recomanded)
    * or the name of your campany
    * or the name of your bundle identifier

    JC
     
  8. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    Was typing on iPad last night...

    Nope, you shouldn't hard code it, better to use JC's code snippet.
     
  9. Bad Sector

    Original Member

    Joined:
    May 28, 2005
    Messages:
    2,742
    Likes Received:
    5
    And don't ever think about taking over my Documents folder :)

    (looks at Spiderweb and Basilisk Games)
     
  10. Shaz

    Moderator Original Member

    Joined:
    Feb 9, 2006
    Messages:
    405
    Likes Received:
    0

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer