void wxTranslationHelper::GetInstalledLanguages(wxArrayString& names, wxArrayLong& identifiers) { names.Clear(); identifiers.Clear(); wxString filename; const wxLanguageInfo* langinfo; names.Add(_("English")); identifiers.Add(wxLANGUAGE_ENGLISH); if (!wxDir::Exists(m_SearchPath)) { wxLogError(_T("Directory %s DOES NOT EXIST"), m_SearchPath.GetData()); return; } wxDir dir(m_SearchPath); int localeid = wxLocale::GetSystemLanguage(); for (bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS); cont; cont = dir.GetNext(&filename)) { langinfo = wxLocale::FindLanguageInfo(filename); if (langinfo != NULL) { wxString mo_file = dir.GetName() + wxFileName::GetPathSeparator() + filename + wxFileName::GetPathSeparator() + _T("LC_MESSAGES") + wxFileName::GetPathSeparator() + catalogname + wxT(".mo"); wxLogInfo(_("SEARCHING FOR %s"), mo_file.GetData()); if (wxFileExists(mo_file)) { if (langinfo->Language == localeid) names.Add(langinfo->Description + _(" (Default)")); else names.Add(langinfo->Description); identifiers.Add(langinfo->Language); } } } }
bool wxGxWebConnectionFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds) { wxGxCatalogBase* pCatalog = GetGxCatalog(); for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- ) { CPLString szExt = CPLGetExtension(pFileNames[i]); if(wxGISEQUAL(szExt, "wconn")) { if( m_bHasDriver ) { wxGxObject* pObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i]); if(pObj) pChildrenIds.Add(pObj->GetId()); } pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); } } return true; }
bool wxGxLocalDBFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds) { wxGxCatalogBase* pCatalog = GetGxCatalog(); bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT; for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- ) { VSIStatBufL BufL; int ret = VSIStatL(pFileNames[i], &BufL); if(ret == 0) { if (VSI_ISDIR(BufL.st_mode) && wxGISEQUAL(CPLGetExtension(pFileNames[i]), "gdb")) { wxGxObject* pObj = GetGxObject(pParent, wxString(CPLGetFilename(pFileNames[i]), wxConvUTF8), pFileNames[i], enumContGDBFolder, bCheckNames); if(pObj) pChildrenIds.Add(pObj->GetId()); pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); } //TODO: mdb, sqlite, db extensions } } return true; }
wxMutexError wxMutexInternal::Lock() { wxMacStCritical critical ; if ( UMASystemIsInitialized() ) { OSErr err ; ThreadID current = kNoThreadID; err = ::MacGetCurrentThread(¤t); // if we are not the owner, add this thread to the list of waiting threads, stop this thread // and invoke the scheduler to continue executing the owner's thread while ( m_owner != kNoThreadID && m_owner != current) { m_waiters.Add(current); err = ::SetThreadStateEndCritical(kCurrentThreadID, kStoppedThreadState, m_owner); err = ::ThreadBeginCritical(); wxASSERT( err == noErr ) ; } m_owner = current; } m_locked++; return wxMUTEX_NO_ERROR; }
bool wxGxPrjFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds) { bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT; for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- ) { CPLString szExt = CPLGetExtension(pFileNames[i]); wxGxObject* pGxObj = NULL; if(wxGISEQUAL(szExt, "prj")) { bool bAdd = true; for(int j = 0; prj_notadd_exts[j] != NULL; ++j ) { if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL)) { bAdd = false; break; } } if(bAdd) { pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumESRIPrjFile, bCheckNames); } pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); } else if(wxGISEQUAL(szExt, "qpj")) { bool bAdd = true; for(int j = 0; prj_notadd_exts[j] != NULL; ++j ) { if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL)) { bAdd = false; break; } } if(bAdd) { pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumQPJfile, bCheckNames); } pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); } else if(wxGISEQUAL(szExt, "spr")) { pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumSPRfile, bCheckNames); pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); } if(pGxObj) { pChildrenIds.Add(pGxObj->GetId()); pGxObj = NULL; } } return true; }
void OpenUserDataRec::MakeUserDataRec( const wxString& filter ) { if ( !filter.empty() ) { wxString filter2(filter) ; int filterIndex = 0; bool isName = true ; wxString current ; for ( unsigned int i = 0; i < filter2.length() ; i++ ) { if ( filter2.GetChar(i) == wxT('|') ) { if ( isName ) { m_name.Add( current ) ; } else { m_extensions.Add( current ) ; ++filterIndex ; } isName = !isName ; current = wxEmptyString ; } else { current += filter2.GetChar(i) ; } } // we allow for compatibility reason to have a single filter expression (like *.*) without // an explanatory text, in that case the first part is name and extension at the same time wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ; if ( current.empty() ) m_extensions.Add( m_name[filterIndex] ) ; else m_extensions.Add( current ) ; if ( filterIndex == 0 || isName ) m_name.Add( current ) ; ++filterIndex ; const size_t extCount = m_extensions.GetCount(); for ( size_t i = 0 ; i < extCount; i++ ) { wxUint32 fileType, creator; wxString extension = m_extensions[i]; // Remove leading '*' if ( !extension.empty() && (extension.GetChar(0) == '*') ) extension = extension.Mid( 1 ); // Remove leading '.' if ( !extension.empty() && (extension.GetChar(0) == '.') ) extension = extension.Mid( 1 ); if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator )) m_filtermactypes.Add( (OSType)fileType ); else m_filtermactypes.Add( '****' ); // We'll fail safe if it's not recognized } } }
bool wxGxRasterFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds) { bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT; for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- ) { wxGxObject* pGxObj = NULL; CPLString szExt = CPLGetExtension(pFileNames[i]); CPLString szPath; bool bContinue(false); unsigned int j; for(j = 0; j < sizeof(raster_exts) / sizeof(raster_exts[0]); ++j) { if(wxGISEQUAL(szExt, raster_exts[j].sExt) ) { if(raster_exts[j].bAvailable) { CPLString szPath(pFileNames[i]); pGxObj = GetGxObject(pParent, GetConvName(szPath), szPath, raster_exts[j].eType, bCheckNames); if(pGxObj != NULL) pChildrenIds.Add(pGxObj->GetId()); } pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); bContinue = true; break; } } if(bContinue) continue; if(wxGISEQUAL(szExt, "prj")) { if(pFileNames) { unsigned int j; for(j = 0; j < sizeof(raster_exts) / sizeof(raster_exts[0]); ++j) { szPath = (char*)CPLResetExtension(pFileNames[i], raster_exts[j].sExt); if(CPLCheckForFile((char*)szPath.c_str(), NULL)) { pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); bContinue = true; break; } } } } if(bContinue) continue; for( j = 0; raster_add_exts[j] != NULL; ++j ) { if(wxGISEQUAL(szExt, raster_add_exts[j])) { pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); break; } } } return true; }