Mailing List
Home
Forum Home
MUD Dev - Discussion of MUD system design, development, and implementation
Mac Game - Mac game development
Rivers of MUD - a Diku and Merc based multiuser dungeon
SMAUG
Subjects
Getting UDP through NAT/firewalls/whatever for a game
Getting UDP through NAT/firewalls/whatever for a game
QuickTime errors
Python script as stand alone MUD server
Various sound problems
Fragment Shaders & GL TEXTURE RECTANGLE EXT
Timers and global variables
Re: Language and platform for Text MUD server
Apparent acquisition of Yantis (mysupersales) by IDE
HID keyboard
Getting UDP through NAT/firewalls/whatever for a game
Microsoft Sparkle
Director MX
Congratulations Horizons
Yet more problems fullscreen mode
Apple Dev Kitchen Them 's tasty vittles, Maw!
NSOpenGLContext, Pbuffers, and drawables
More DCR "theft " naughtiness
dynamic sprite creation and imaging lingo
Re: Find stuff in Flash array?
Effects of skill imbalances?
QuickTime errors
Rom 2 4/Quickmud Enhancement/Bug fix
Working with XML files/CFURL
smooth scrolling/subpixel tweening
RE: (Ron help me?) Flash text
Flash Racing
MudDev FAQ 2
Browser based games
Installing GLUT
Special character in Flash XML
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Working with XML files/CFURL

Working with XML files/CFURL

2003-11-21       - By William MacKay

 Back
Reply:     1     2     3     4     5  

Here's what i do to create the CFURL to a file in my bundle:

CFStringRef fileString = CFStringCreateWithCString(kCFAllocatorDefault,  
"tankmodel", kCFStringEncodingMacRoman);
CFStringRef extensionString =  
CFStringCreateWithCString(kCFAllocatorDefault, "lwo",  
kCFStringEncodingMacRoman);
CFURLRef fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),  
fileString, extensionString, NULL);

That creates a CFURLRef to  
"MyGame.app/Contents/Resources/tankmodel.lwo". If you can hardcode the  
filename and/or its extension, you can pass CFSTR("lwo"), for instance,  
instead of having to create a seperate variable. Then i can load the  
file with:

CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, fileURL,  
&fileRef, NULL, NULL, &err);

That's the best way i know of to create a CFURLRef to a file within  
your bundle. If you're accessing a file outside of your bundle, i'm  
sorry to say i've never done that before. But i found a whole bunch of  
functions that might help you at  
<http://developer.apple.com/documentation/CoreFoundation/Reference/
CFURLRef/Reference/function_group_1.html>. It looks like  
CFURLCreateFromFileSystemRepresentation is what you'd need. But there's  
a higher level version of the same call named  
CFURLCreateWithFileSystemPath. And if you're getting an FSRef from a  
file dialog or something you can use CFURLCreateFromFSRef.

Good luck, i hope this helps.

-William MacKay

On 21 Nov 2003, at 00:36, m.b. wrote:

> The doc's suggest I use CFURLCreateDataAndPropertiesFromResource to  
> load the xml doc into memory to begin working with it.  Well, digging  
> around I found that it might be easiest to use  
> CFURLCreateFromFileSystemRepresentation.  That is where i'm having  
> trouble.  Before I go asking for help on how to use that am I correct  
> in assuming that is the best method to get the CFURLRef for a file in  
> my filesystem and should I ask this elsewhere?
>
> on to asking for help....
>
> In doing more research to make sure that I am truly stuck, I believe  
> the issue i'm struggling with most is either because of "sourceURL" in  
> this example from the docs:
>
> <begin qoute>
> // Load the XML data using its URL.
> CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,
>                 sourceURL, &xmlData, NULL, NULL, NULL);
>
> // Parse the XML and get the CFXMLTree.
> cfXMLTree = CFXMLTreeCreateFromData(kCFAllocatorDefault,
>                     xmlData,
>                     sourceURL,
>                     kCFXMLParserSkipWhitespace,
>                     kCFXMLNodeCurrentVersion);
> <end quote>
>
> I cant seem to figure out how to set up sourceURL correctly.
>
> at this point in my games development i'm working on fine tuning some  
> statistics, (an easy enough place to start) and I'm trying to read  
> from a data and write back to it and other files, I figured XML is the  
> way to go with the Core Foundations High Level parser.  Let me know if  
> I might want to try something else.
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
mac-games-dev mailing list | mac-games-dev@(protected)
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac
-games-dev
Do not post admin requests to the list. They will be ignored.

Earn $52 per hosting referral at Lunarpages.