Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to? Find contents of an applications current directory.

How to? Find contents of an applications current directory.
Thread Tools
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Nov 8, 2001, 02:28 PM
 
Here is my problem. I am programming a game...I got a graphics engine mostly finished, got a start on the Ai, mostly everything is fine. But I have never really had to work with directories and files very much in the past, and with OS X I am even more lost than I was before. The apple docs are rather vague about how to use things such as the file manager and the related things.

This game is a carbon app...

---------------------------
How do I find out the contents of directory in which my application is currently in, and store this in some data structure that I can display to the user so that they can load their saved game. (This has to be an ingame interface, right now I am using apple's choose file interface thing)

Any suggestions on API's to use, example code, pretty much anything would be appreciated.
     
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status: Offline
Reply With Quote
Nov 9, 2001, 07:37 AM
 
Don't store user-specific data with the game (you don't have write permissions there anyways). Get the user's preferences folder and store your data in it. See the FindFolder API (AFAIK).

In that preferences file, use any format you like (e.g. XML or resources). You don't need to search for any files.
     
Forum Regular
Join Date: Jan 2001
Location: Boston, MA
Status: Offline
Reply With Quote
Nov 9, 2001, 09:11 AM
 
Definitely use FindFolder() to locate the user's preferences directory. The other API you might want to check out to make your life really simple is CFPreferences. It takes care of writing out prefs to the right location in XML through a simple API. Very neat stuff. You don't have to worry about opening files, writing data, parsing, etc. It does it for you.
     
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Nov 14, 2001, 06:44 PM
 
By application's current working directory, I am talking about a folder called something like "My App Folder" with "My App" inside of it. My design calls for something similar to the way that a game such as unreal tournament keeps track of things like maps. They are kept in the unreal tournament folder in a folder called "Maps". This allows us to allow users to download new maps over the internet and install them themselves.

Alright that sounds like a good idea for saving the user preferences.

My other problem is that I need to load maps from a map folder, and I need to save those maps when the user exits that location (Each user has a seperate folder that the app stores their maps in).

You know what, I am going to save the maps that the game saves for each user in the preferences folder. But there is still a problem.

I gotta load the maps from the application's directory. How do I do this, and instead of doing this should I store things such as maps in a package along the with the application?
     
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Nov 14, 2001, 06:49 PM
 
And yes FindFolder() seems to make sense, I can across this in my reading but dismissed it as a candidate.

This is why forums are such a great thing...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:49 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2