PDA

View Full Version : MacOS shared save game location


Josh Jensen
05-03-2007, 02:25 PM
I've searched far and wide for the answer to this, and I guess I'm just searching for the wrong thing. On Windows, I store Pathstorm's shared save game information (accessible from multiple users) at CSIDL_COMMON_APPDATA (the equivalent of %ALLUSERSPROFILE%\Application Data\). Even though Pathstorm doesn't have per-user save game information, the game is architected to put it at CSIDL_APPDATA (the equivalent of %APPDATA%).

What are the Mac equivalents of these? It's obvious user save game data would go somewhere in the user's home directory (where?), but I need a place for the shared save game data.

Any ideas? Thanks in advance!

Tom Gilleland
05-03-2007, 03:12 PM
I store everything in:

harddriveName/Users/UserName/Library/Preferences/fileName

Some developers make a folder at the fileName location and put their multiple files in there.

-Tom

Josh Jensen
05-03-2007, 03:26 PM
Wonderful. I hadn't noticed that tree before, but I'm a Mac newbie.

Is there an API to retrieve /Users/Shared/? The environment variable HOME can be used to get to /Users/username/. Is /Users/Shared/ guaranteed to always be at /Users/Shared/? Also, /Users/Shared/Library/Preferences/ does not exist. Should it be created, or is it proper etiquette for me to store my data at /Users/Shared/Cavebug Games/Pathstorm/ ?

Thanks!

GolfHacker
05-03-2007, 05:31 PM
I store everything in:

harddriveName/Users/UserName/Library/Preferences/fileName

Some developers make a folder at the fileName location and put their multiple files in there.

-Tom

Interesting. I just retrieve the HOME environment variable, and append "/Library/Application Support/my-app/myfilename".

Just for my own knowledge, is the hard drive name really needed? Is there a possibility the HOME environment variable wouldn't cover this? Also, I was told on idevgames that "Application Support" was the proper place. Is "Preferences" better? What's the difference?

Tom Cain
05-03-2007, 06:25 PM
I believe the locations for application files to be accessed by all users are:

HardDrive/Library/Application Support/
HardDrive/Library/Preferences/

These are not the same as the user versions, these are at the system level. One way to get them is through the Carbon API, using the Folder Manager's FindFolder function.

The Application Support folder is generally for storing plugins, extras, install logs, and other things that are read-only. The Preferences folder is for storing things that will be updated/written to, like preference files.

Not all apps follow this. Some put items that usually go in Application Support into a folder they create in the Preferences folder. This will still work.

Red Marble Games
05-04-2007, 05:44 AM
This actually can be a difficult issue. You can't put anything you want multiple users to be able to reach at (HOME)/[anything], or at /Users/username/[anything], because if a different user logs into the Mac they won't have access to those files. (And Mac users do log in different users, especially when kids use Mom's computer). And Apple apparently doesn't want you using /Users/Shared, though that otherwise would be the best solution. The paths that Tom mentions often will work, but as I recall you can't get access to those paths if you're logged into the Mac as a non-admin user, so you need to allow for the possibility that those calls will fail.

So what's the solution? There isn't a great one, but probably /Users/Shared/ for now. Despite Apple's frowning on it I think there is some sample code at developer.apple.com that shows an example of saving high scores to that directory.

Mark