// GetNumProcessors //------------------------------------------------------------------------------ /*static*/ uint32_t Env::GetNumProcessors() { #if defined( __WINDOWS__ ) // Default to NUMBER_OF_PROCESSORS uint32_t numProcessors = 1; AStackString< 32 > var; if ( GetEnvVariable( "NUMBER_OF_PROCESSORS", var ) ) { if ( sscanf_s( var.Get(), "%u", &numProcessors ) != 1 ) { numProcessors = 1; } } return numProcessors; #elif defined( __LINUX__ ) || defined( __APPLE__ ) long numCPUs = sysconf( _SC_NPROCESSORS_ONLN ); if ( numCPUs <= 0 ) { ASSERT( false ); // this should never fail numCPUs = 1; } return ( uint32_t )numCPUs; #else #error Unknown platform #endif }
CString CGetEnvPath::GetRealPath(LPCTSTR pszEnvPath) { CString strResult; if (pszEnvPath == NULL) { strResult = _T(""); goto Exit0; } int nFirstPos = 0; int nSecondPos = 0; BOOL bFind = FALSE; strResult = pszEnvPath; bFind = FindEnvironmentPos(strResult, nFirstPos, nSecondPos); if (bFind == TRUE) { CString strLeft ; CString strRight ; CString strEnvName ; CString strEnvVariable; strLeft = strResult.Left(nFirstPos); strRight = strResult.Mid (nSecondPos + 1); strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1); strEnvVariable = GetEnvVariable(strEnvName); if (strEnvVariable.GetLength() <= 0) strEnvVariable = GetFolderPath( strEnvName ); if(strEnvVariable.Find(_T(';')) == -1) strResult = CombinationPath(strLeft, strEnvVariable, strRight); else { //SplitString() std::vector<CString> strvec; SplitString(strEnvVariable,_T(';'), strvec); strResult = _T(""); for(std::vector<CString>::iterator it = strvec.begin();it != strvec.end(); it++) { strResult += CombinationPath(strLeft, (*it), strRight); strResult += _T(";"); } } bFind = FindEnvironmentPos(strResult, nFirstPos, nSecondPos); } Exit0: return strResult; }