File Code Problems
Try this code. It works perfectly for me. If it doesn't work for you, please tell me.
Good luck!
-Tobi
Code:
int main(void)
{
CFBundleRef bundle;
CFURLRef bundle_url;
CFStringRef sr;
int i;
char routePath[1024];
char worldmapPath[1024];
FSSpec f;
FSRef fsr;
short ref;
//Get the application directory as a POSIX path and store it in routePath
bundle = CFBundleGetMainBundle();
if ( ! bundle )
return 0;
bundle_url=CFBundleCopyBundleURL( bundle );
if ( ! bundle_url )
return 0;
sr=CFURLCopyFileSystemPath(bundle_url, kCFURLPOSIXPathStyle);
if ( ! sr )
return 0;
if (!CFStringGetCString(sr, routePath, 1024, kCFStringEncodingASCII) )
return 0;
CFRelease( bundle_url );
CFRelease( sr );
#ifdef __APPLE_CC__
//When you are using ProjectBuilder routePath also contains the application title at the end. This deletes it.
for (i=strlen(routePath)-1; i>0; i--)
{
if (routePath[i]=='/'){routePath[i]='\0';break;}
routePath[i]='\0';
}
#endif
strcat(routePath, "/");
//Build the path of the world map file
sprintf(worldmapPath, "%sFiles/World Map", routePath);
FSPathMakeRef(worldmapPath, &fsr, NULL);//Convert to FSSpec
FSGetCatalogInfo (&fsr, NULL, NULL, NULL, &f, NULL);//Convert to FSRef
FSpOpenDF(&f, fsRdWrPerm, &ref);//Open data fork
return 0;
}Good luck!
-Tobi
| Messages In This Thread |
|
File Code Problems - Muffinking - Jun 6, 2002, 05:12 PM
File Code Problems - Tobi - Jun 9, 2002 10:20 PM
File Code Problems - wadesworld - Jun 10, 2002, 11:56 PM
File Code Problems - WFleming - Jun 11, 2002, 01:42 AM
File Code Problems - OneSadCookie - Jun 11, 2002, 02:51 AM
File Code Problems - WFleming - Jun 11, 2002, 04:10 AM
File Code Problems - geezusfreeek - Jun 11, 2002, 08:14 AM
File Code Problems - WFleming - Jun 11, 2002, 03:58 PM
File Code Problems - geezusfreeek - Jun 11, 2002, 04:11 PM
File Code Problems - wadesworld - Jun 13, 2002, 10:06 PM
File Code Problems - Josh - Jun 14, 2002, 08:47 AM
File Code Problems - geezusfreeek - Jun 14, 2002, 11:18 AM
File Code Problems - WFleming - Jun 14, 2002, 04:14 PM
File Code Problems - Josh - Jun 14, 2002, 05:32 PM
File Code Problems - WFleming - Jun 17, 2002, 05:13 PM
File Code Problems - Josh - Jun 17, 2002, 05:33 PM
File Code Problems - WFleming - Jun 17, 2002, 06:54 PM
|
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Recursively Packing Source Code Into One File? | daveh84 | 15 | 6,654 |
Feb 3, 2010 08:36 PM Last Post: AndyKorth |
|
| Carbon File Code | Muffinking | 5 | 4,344 |
Jun 3, 2002 12:23 AM Last Post: henryj |
|

