Game Development Community

Common application folder

by Very Interactive Person · in Torque Game Engine · 01/21/2007 (4:58 am) · 5 replies

I'm new to mac and mac development. But recently I bought me a second hand mac mini, so I can port my games to mac.
Downloaded XCode, and to my surprise I was able to compile without any problems :)

So, now I need to add everything I changed to the TGB source for the windows version, to the mac version.
Most of that wasn't a problem. But the resource posted in this thread : www.garagegames.com/mg/forums/result.thread.php?qt=55841 (TGB forums, but since there's no mac specific forum there, I thought it was best to post it here), is windows only. So, does someone around here know how to add the mac platform function?
Basically I need to write some info to a common folder. So when the user deletes the game, uninstalls it, or moves it, the application can still acces that information (when re-installed). On windows there's a common application data folder for this purpose, or one could use the registry. Because i'm not familiar with OSX, I'm not sure which folder to use. But I'm sure there's something similar for mac.

#1
01/21/2007 (9:43 am)
~/Library/Application Support/Your-app-name

Alternatively, I'm lazy, so I usually just use the same code as I use on linux, which writes to ~/.appname/. Not entirely pleasing to mac users, but more acceptable than writing to the game dir itself.

Gary (-;
#2
01/25/2007 (1:39 pm)
@Ward: What's the function of the data you want to leave around?
It's purpose will affect where mac users will expect it to go.
#3
04/10/2007 (11:37 am)
Ok, a couple of months later and I still haven't found time to give this a try. Especially becuase I can't seem to find good information on this subject, and I don't know enough about OSX.
Anyway, someone told me I should be writing the files to the users Library/Preferences folder. What's the difference with the Application support folder? And how do I get the path to those folders from C++? Or how do I get the current user in C++?
#4
04/11/2007 (12:23 pm)
@Ward. There are several places it *could* go, the purpose of the data, it's function, what it does, will affect where it *should* go. What's the function of the data you want to leave around?

Here's a ton of info on the subject:
developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Articles/Librar...

In C, you can get the path to the user's home directory pretty simply. There is a special path wildcard that expands to the user's home dir: "~". To get the user's preferences directory, you'd pass "~/Library/Preferences/" to the file APIs.
If you have a lot of files to put in a directory, you should create a subfolder of that directory, and write your files to the subfolder. Also, you should always avoid overwriting user's files.

Share and Enjoy.
/Paul
#5
04/11/2007 (12:28 pm)
Thanks, that was the information I was looking for.

I need to write some files to make a time limited demo... so, I'm not going to say here exactly what I am going to do ;) But I'm sure you understand what I'm after.