Carbon File Code - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Carbon File Code (/thread-7734.html)
Carbon File Code - Muffinking - May 28, 2002 01:45 PM
Can someone give me a very simple function that finds a file called "World Map" inside of the folder "Senario Files".
the names don't matter much, but I need some code that creates an FSSpec to the file. The Directory is in the same one as the App.
I just need the bare minimum..
I was told in a previous message I sent that in OS X the file system works differently and when you specify a file by something like "\p:Senario Files:World Map" it doesn't initally look in the apps directory but else where.
I have looked at documentation on the apple site and haven't yet found what I am looking for. I will continue to search until I get a response here.
PS: I am working with the DataFork.
Carbon File Code - Tobi - May 28, 2002 10:17 PM
You first have to find out the directory your application is in. Then create a string with the full pathname of the file and last convert it to an FSSpec.
Here's the code I use for this:
Carbon File Code - GoodDoug - May 30, 2002 01:52 PM
Though, if yopu can swing it, working with FSRefs is much better. FSSpec stuff on MacOS X is pretty hacky, though it can mostly work. There are FSRef calls that are corrollary to most FSSpec file system calls. The only issue is in using Quicktime ro some other API that hasn't moved to FSRefs.
Carbon File Code - wadesworld - May 31, 2002 09:54 PM
Here's what I use. Note that my purpose in this code is to get the top level of the application package directory. Thus, once I get the path to the executable, I chop off the last directory in the path.
Carbon File Code - Tobi - Jun 1, 2002 02:27 AM
Both methods should work well. I'm not experienced with all those new CFString..., CFBundle... calls so I'm using a more "traditional" code . The advantage of wadesworld's solution is that you don't need any parameters for your main function and can simply create an "int main(void)".
Carbon File Code - henryj - Jun 3, 2002 12:23 AM
Just this afternoon I decided I should learn how to use the CFBundle stuff for creating file paths. I thought I'd just check idev to see if there was anything useful and bingo.
Thanks wade, that code is exactly what I was after.