2

I'm porting a windows game to Mac OS X. I was wondering where I should store game data such as saved games, user profiles, etc and how I can retrieve that path programmatically in C++?

The game will be delivered as a "modern bundle" as specified here

Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210

3 Answers3

6

Save it under ~/Library/Application Support/Your Game Name/

where "~" stands for the home directory of the user playing your game.

You may want to give this a read: http://cocoadevcentral.com/articles/000084.php

diciu
  • 29,133
  • 4
  • 51
  • 68
  • No it is not working for me. There is no Library under user/my_name, only one under user/shared. – OMGPOP Jan 01 '13 at 10:48
  • Library is hidden by default (At least on Lion anyway), you can make it visible through the terminal: http://www.wikihow.com/See-Hidden-Folders-on-Mac-OS-X-and-Other-Recent-Models ... or you can view hidden files in a file-open dialog by hitting CMD+Shift+Period – Danny Parker Apr 15 '13 at 14:12
  • This doesn't seem to work anymore when the Application needs to be sandboxed. – Wizard of Kneup Mar 23 '17 at 04:58
4
~/Library/Application Support/GameName

You can access Cocoa objects using Objective-C++, this can be done by changing the suffix of to source code to .mm This enables you to combine both Objective-C and C++.

There are several file system classes you can use.

Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
3

I know you've already accepted an answer, but let me file a complaint about the previous answers: ~/Library/Application Support is not one of the places non-technical users will look for data files. You might want to at least consider putting them in a new folder in the Documents directory; i.e., ~/Documents/MyGame.

Mike Heinz
  • 1,787
  • 1
  • 17
  • 23