bool wxDynamicLibrary::Load(const wxString& libnameOrig, int flags) { wxASSERT_MSG(m_handle == 0, _T("Library already loaded.")); // add the proper extension for the DLL ourselves unless told not to wxString libname = libnameOrig; if ( !(flags & wxDL_VERBATIM) ) { // and also check that the libname doesn't already have it wxString ext; wxFileName::SplitPath(libname, NULL, NULL, &ext); if ( ext.empty() ) { libname += GetDllExt(); } } // different ways to load a shared library // // FIXME: should go to the platform-specific files! #if defined(__WXMAC__) && !defined(__DARWIN__) FSSpec myFSSpec; Ptr myMainAddr; Str255 myErrName; wxMacFilename2FSSpec( libname , &myFSSpec ); if( GetDiskFragment( &myFSSpec, 0, kCFragGoesToEOF, "\p", kPrivateCFragCopy, &m_handle, &myMainAddr, myErrName ) != noErr ) { wxLogSysError( _("Failed to load shared library '%s' Error '%s'"), libname.c_str(), wxMacMakeStringFromPascal( myErrName ).c_str() ); m_handle = 0; } #elif defined(__WXPM__) || defined(__EMX__) char err[256] = ""; DosLoadModule(err, sizeof(err), (PSZ)libname.c_str(), &m_handle); #else m_handle = RawLoad(libname, flags); #endif if ( m_handle == 0 ) { #ifdef wxHAVE_DYNLIB_ERROR Error(); #else wxLogSysError(_("Failed to load shared library '%s'"), libname.c_str()); #endif } return IsLoaded(); }
bool wxDynamicLibrary::Load(const wxString& libnameOrig, int flags) { wxASSERT_MSG(m_handle == 0, wxT("Library already loaded.")); // add the proper extension for the DLL ourselves unless told not to wxString libname = libnameOrig; if ( !(flags & wxDL_VERBATIM) ) { // and also check that the libname doesn't already have it wxString ext; wxFileName::SplitPath(libname, NULL, NULL, &ext); if ( ext.empty() ) { libname += GetDllExt(wxDL_MODULE); } } m_handle = RawLoad(libname, flags); if ( m_handle == 0 && !(flags & wxDL_QUIET) ) { #ifdef wxHAVE_DYNLIB_ERROR Error(); #else wxLogSysError(_("Failed to load shared library '%s'"), libname.c_str()); #endif } return IsLoaded(); }
bool wxDynamicLibrary::Load(const wxString& libnameOrig, int flags) { wxASSERT_MSG(m_handle == 0, wxT("Library already loaded.")); // add the proper extension for the DLL ourselves unless told not to wxString libname = libnameOrig; if ( !(flags & wxDL_VERBATIM) ) { // and also check that the libname doesn't already have it wxString ext; wxFileName::SplitPath(libname, NULL, NULL, &ext); if ( ext.empty() ) { libname += GetDllExt(wxDL_MODULE); } } // different ways to load a shared library // // FIXME: should go to the platform-specific files! #if defined(__WXPM__) || defined(__EMX__) char err[256] = ""; DosLoadModule(err, sizeof(err), libname.c_str(), &m_handle); #else // this should be the only remaining branch eventually m_handle = RawLoad(libname, flags); #endif if ( m_handle == 0 && !(flags & wxDL_QUIET) ) { #ifdef wxHAVE_DYNLIB_ERROR Error(); #else wxLogSysError(_("Failed to load shared library '%s'"), libname.c_str()); #endif } return IsLoaded(); }