Jump to content
  • Advertisement
Sign in to follow this  
Daggerbot

Save data on Windows and OS X

This topic is 2989 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My project is concurrently being ported to the Windows, Mac OS X, and Linux (and similar *nix) platforms. On Windows and on Mac, where is the preferred place to store a game's save files? On the Linux port, it is stored in '$HOME/.appname'. On Windows, should it be stored in...

A. the game's program directory, or
B. the current user's application data directory?

I've seen both used by games, but A appears to be more common. This would allow the user to access their save data from any profile, but B would protect the user's data from other users.

Similarly, on OS X, should the save data be stored in...

A. the game's .app (which itself is a directory when you look under the hood), or
B. in something like '$HOME/.appname', like the Linux port?

I haven't used OS X enough to know these technical details, but I intend to get a Mac in the near future for game development. Until then I'm looking for help on some of these details. Any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
With regards to Windows, don't go saving anything in the program directory! Keep in mind that your application probably won't even have write access to its own folder, at least on Vista and later. The best place to store this data is in the user's data directory, which can be obtained via SHGetKnownFolderPath (also SHGetFolderPath, which is deprecated, but I don't know if the other function is available prior to Vista). As an added bonus, the user can uninstall the game but still retain their save files if they chose. I'm not sure about other platforms, but I imagine that similar rules apply.

Share this post


Link to post
Share on other sites
I haven't extensively used any version of Windows after XP, but it appears that they improved security a bit on Vista if program folders are write protected by default. Would GetEnvironmentVariable(_T("APPDATA"), ...) be a good way to get the application data directory on all versions of windows?

Share this post


Link to post
Share on other sites
I'd recommend just using SHGetFolderPath() - I'd stay clear of environment variables (Although I don't really know if there's any particular reason to avoid them, but I personally wouldn't trust them to stay the same across different Windows versions).

Share this post


Link to post
Share on other sites
Quote:
Original post by Daggerbot
Similarly, on OS X, should the save data be stored in...

A. the game's .app (which itself is a directory when you look under the hood), or
B. in something like '$HOME/.appname', like the Linux port?

$HOME/Library/<Application Name>/

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
Quote:
Original post by Daggerbot
Similarly, on OS X, should the save data be stored in...

A. the game's .app (which itself is a directory when you look under the hood), or
B. in something like '$HOME/.appname', like the Linux port?

$HOME/Library/<Application Name>/

Careful. This will fail on non-english OSX versions (the Library folder may be named differently).

Use QuerySystemFolder(kApplicationSupportFolderType) instead.

Share this post


Link to post
Share on other sites
Quote:
Original post by Gamer Gamester
Are there any size-restrictions to what you put in these paths?

File size wise ? None that I know of.

Quote:

Specifically, are these paths also the best option for DLC (Downloadable Content)?

Typically yes. These folders have the advantage of not requiring an elevated token for write access. The main executable location should never be written to once the application was installed, except by an installer for software maintenance purposes (updating, patching, uninstalling, etc). This will require admin privileges on Vista and higher. All user content should be placed in the appropriate user data folders instead.

Share this post


Link to post
Share on other sites
Quote:
Original post by Yann L
Quote:
Original post by Oluseyi
$HOME/Library/<Application Name>/

Careful. This will fail on non-english OSX versions (the Library folder may be named differently).

Use QuerySystemFolder(kApplicationSupportFolderType) instead.

Excellent call. Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!