-#if defined(WXMAKINGDLL) && defined(__DARWIN__)
- // Open the shared library resource file if it is not yet open
- if (gCurrentResource == -1) {
- NSSymbol theSymbol;
- NSModule theModule;
- const char *theLibPath;
-
- gDylibBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.wxwindows.wxWindows"));
- if (gDylibBundle != NULL) {
- // wxWindows has been bundled into a framework
- // load the framework resources
-
- gCurrentResource = CFBundleOpenBundleResourceMap(gDylibBundle);
- }
- else {
- // wxWindows is a simple dynamic shared library
- // load the resources from the data fork of a separate resource file
- char *theResPath;
- char *theName;
- char *theExt;
- FSRef theResRef;
- OSErr theErr = noErr;
-
- // get the library path
- theSymbol = NSLookupAndBindSymbol("_gCurrentResource");
- theModule = NSModuleForSymbol(theSymbol);
- theLibPath = NSLibraryNameForModule(theModule);
-
- wxLogDebug( theLibPath );
-
- // allocate copy to replace .dylib.* extension with .rsrc
- theResPath = strdup(theLibPath);
- if (theResPath != NULL) {
- theName = strrchr(theResPath, '/');
- if (theName == NULL) {
- // no directory elements in path
- theName = theResPath;
- }
- // find ".dylib" shared library extension
- theExt = strstr(theName, ".dylib");
- // overwrite extension with ".rsrc"
- strcpy(theExt, ".rsrc");
-
- wxLogDebug( theResPath );
-
- theErr = FSPathMakeRef((UInt8 *) theResPath, &theResRef, false);
- if (theErr != noErr) {
- // try in current directory (using name only)
- theErr = FSPathMakeRef((UInt8 *) theName, &theResRef, false);
- }
-
- // free duplicated resource file path
- free(theResPath);
-
- // open the resource file
- if (theErr == noErr) {
- theErr = FSOpenResourceFile( &theResRef, 0, NULL, fsRdPerm,
- &gCurrentResource);
- }
- }
- }
-
- /*
- char *path;
- int i, len;
-
- if( i++ > 0 ) {
- len = i + strlen(rPath);
- path = (char*) malloc(len+1);
- }
- else {
- // try current directory
- myerr = FSPathMakeRef((UInt8 *) rPath, &myref, false);
- }
- */
- }
-#endif /* WXMAKINGDLL && __DARWIN__ */
-
- m_currentRefNum = CurResFile() ;
- if ( gCurrentResource != -1 )
- {
- UseResFile( gCurrentResource ) ;
- }