void CArgMap::MergeFromString ( const SString& strLine, bool bAllowMultiValues ) { std::vector < SString > parts; strLine.Split( m_strPartsSep, parts ); for ( uint i = 0 ; i < parts.size () ; i++ ) { SString strCmd, strArg; parts[i].Split ( m_strArgSep, &strCmd, &strArg ); if ( !bAllowMultiValues ) m_Map.erase ( strCmd ); if ( strCmd.length () ) // Key can not be empty MapInsert ( m_Map, strCmd, strArg ); } }
//////////////////////////////////////////////////////////////////////// // 描 述: 取当前路径 // 作 者: 邵凯田 // 创建时间: 2011-11-18 11:44 // 参数说明: void // 返 回 值: 当前路径,含路径分隔符 ////////////////////////////////////////////////////////////////////////// SString SDir::currentPath() { SString str; char currentName[SKT_PATH_MAX+1]; memset(currentName,0,SKT_PATH_MAX+1); #ifdef WIN32 GetModuleFileName(NULL,currentName,SKT_PATH_MAX); str = currentName; int pos=str.findRev("/"); if(pos<0) pos = str.findRev("\\"); if(pos>0) str = str.left(pos+1); #else if(getcwd(currentName,SKT_PATH_MAX)) str = currentName; else str = ""; if(str.right(1) != "/") str += "/"; #endif return str; }
/////////////////////////////////////////////////////////////////////////// // // SharedUtil::GetSystemErrorMessage // // Get Windows error message text from a last error code. // /////////////////////////////////////////////////////////////////////////// SString SharedUtil::GetSystemErrorMessage ( uint uiError, bool bRemoveNewlines, bool bPrependCode ) { SString strResult; LPSTR szErrorText = NULL; FormatMessageA ( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, uiError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&szErrorText, 0, NULL ); if ( szErrorText ) { strResult = szErrorText; LocalFree ( szErrorText ); szErrorText = NULL; } if ( bRemoveNewlines ) strResult = strResult.Replace ( "\n", "" ).Replace ( "\r", "" ); if ( bPrependCode ) strResult = SString ( "Error %u: %s", uiError, *strResult ); return strResult; }
////////////////////////////////////////////////////////// // // ShouldUseExeCopy // // Returns true if patches should be applied to exe copy // ////////////////////////////////////////////////////////// bool ShouldUseExeCopy( void ) { SString strUseCopyReason; if ( GetApplicationSettingInt( "nvhacks", "optimus" ) ) strUseCopyReason = GetApplicationSettingInt( "nvhacks", "optimus-rename-exe" ) == 0 ? "" : "optimus-rename-exe"; else strUseCopyReason = GetApplicationSettingInt( "driver-overrides-disabled" ) == 0 ? "" : "driver-overrides-disabled"; if ( GetPatchRequirementAltModules() ) strUseCopyReason += " AltModules"; if ( RequiresAltTabFix() ) strUseCopyReason += " AltTabFix"; // Log reason for using proxy_sa static SString strUseCopyReasonPrevious; if ( strUseCopyReasonPrevious != strUseCopyReason ) { WriteDebugEventAndReport( 3500, SString( "Using proxy_sa because: %s", *strUseCopyReason ) ); strUseCopyReasonPrevious = strUseCopyReason; } return !strUseCopyReason.empty(); }
// // What to do on next restart // bool SharedUtil::GetOnRestartCommand ( SString& strOperation, SString& strFile, SString& strParameters, SString& strDirectory, SString& strShowCmd ) { SString strOnRestartCommand = GetRegistryValue ( "", "OnRestartCommand" ); SetOnRestartCommand ( "" ); std::vector < SString > vecParts; strOnRestartCommand.Split ( "\t", vecParts ); if ( vecParts.size () > 5 && vecParts[0].length () ) { SString strVersion ( "%d.%d.%d-%d.%05d", MTASA_VERSION_MAJOR, MTASA_VERSION_MINOR, MTASA_VERSION_MAINTENANCE, MTASA_VERSION_TYPE, MTASA_VERSION_BUILD ); if ( vecParts[5] == strVersion ) { strOperation = vecParts[0]; strFile = vecParts[1]; strParameters = vecParts[2]; strDirectory = vecParts[3]; strShowCmd = vecParts[4]; return true; } AddReportLog( 4000, SString ( "OnRestartCommand disregarded due to version change %s -> %s", vecParts[5].c_str (), strVersion.c_str () ) ); } return false; }
/////////////////////////////////////////////////////////////// // // FindFiles // // Find all files or directories at a path // If sorted by date, returns last modified last // /////////////////////////////////////////////////////////////// std::vector < SString > SharedUtil::FindFiles ( const SString& strInMatch, bool bFiles, bool bDirectories, bool bSortByDate ) { std::vector < SString > strResult; std::multimap < uint64, SString > sortMap; SString strMatch = PathConform ( strInMatch ); if ( strMatch.Right ( 1 ) == PATH_SEPERATOR ) strMatch += "*"; WIN32_FIND_DATAW findData; HANDLE hFind = FindFirstFileW ( FromUTF8( strMatch ), &findData ); if( hFind != INVALID_HANDLE_VALUE ) { do { if ( ( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ? bDirectories : bFiles ) if ( wcscmp ( findData.cFileName, L"." ) && wcscmp ( findData.cFileName, L".." ) ) { if ( bSortByDate ) MapInsert( sortMap, (uint64&)findData.ftLastWriteTime, ToUTF8( findData.cFileName ) ); else strResult.push_back ( ToUTF8( findData.cFileName ) ); } } while( FindNextFileW( hFind, &findData ) ); FindClose( hFind ); } // Resolve sorted map if required if ( !sortMap.empty() ) { for ( std::multimap < uint64, SString >::iterator iter = sortMap.begin() ; iter != sortMap.end() ; ++iter ) strResult.push_back ( iter->second ); } return strResult; }
int CLuaFunctionDefs::AddAccount ( lua_State* luaVM ) { // account addAccount ( string name, string pass[, bool allowCaseVariations = false ] ) SString strName; SString strPassword; bool bAllowCaseVariations; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strName ); argStream.ReadString ( strPassword ); argStream.ReadBool ( bAllowCaseVariations, false ); if ( !argStream.HasErrors () ) { if ( !bAllowCaseVariations ) { // Message for new behaviour SString strCaseVariation = m_pAccountManager->GetActiveCaseVariation( strName ); if ( !strCaseVariation.empty() ) argStream.SetCustomError ( SString( "Already an account using a case variation of that name ('%s')", *strCaseVariation ) ); } if ( !argStream.HasErrors () ) { CAccount* pAccount; if ( ( pAccount = CStaticFunctionDefinitions::AddAccount ( strName, strPassword ) ) ) { lua_pushaccount ( luaVM, pAccount ); return 1; } } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
//////////////////////////////////////////////////////////////////////// // 描 述: 清除指定目录下的全部内容,同时递归清除全部子目录,不清除指定的目录自身 // 作 者: 邵凯田 // 创建时间: 2011-11-18 11:40 // 参数说明: @dir为指定的目录 // 返 回 值: true清除成功,false表示清除失败 ////////////////////////////////////////////////////////////////////////// bool SDir::clearDir(SString sPath)//清除指定目录下的全部内容 { if(sPath.Right(1) != "\\" && sPath.Right(1) != "/") { #ifdef WIN32 sPath += "\\"; #else sPath += "/"; #endif } SDir dir(sPath,"*"); bool err = false; int i,cnt = dir.count(); for(i=0;i<cnt;i++) { SString sFile = dir[i]; if(sFile == "." || sFile == "..") continue; SString attr = dir.attribute(i); if(SString::GetAttributeValueI(attr,"isdir") == 1) { if(!clearDir(sPath+sFile)) err = true; if(!SDir::removeDir(sPath+sFile)) err = true; } else { if(!SFile::remove(sPath+sFile)) err = true; } } if(err) return false; return true; }
bool SPostgres::Execute(SString sql) { LOGBASEDEBUG("into SPostgres::Execute(%s)",sql.data()); sql = sql.replace("\\","\\\\");//postgres数据库SQL中\为转义符 if(m_pConn == NULL) { LOGWARN("m_pConn is NULL is SPostgres::Execute, Connect it at first!"); Connect(); if(m_pConn == NULL) { LOGWARN("m_pConn is NULL is SPostgres::Execute, Connect error!"); return false; } } PGresult *pRes = PQexec(m_pConn,sql.data()); if(PQresultStatus(pRes) != PGRES_COMMAND_OK ) { SString err; err.sprintf("Error in SPostgres::Execute(%s), err=%s",sql.data(),PQresultErrorMessage(pRes)); LOGERROR("%s",err.data()); if(pRes != NULL) PQclear(pRes); if(TestConnect() == true)//连接可用 return false; //失败自动重连一次数据库 if(!Reconnect()) return false;//连接失败 pRes = PQexec(m_pConn,sql.data()); if(PQresultStatus(pRes)!=PGRES_COMMAND_OK) { LOGERROR("Error in SPostgres::Execute(%s), err=%s",sql.data(),PQresultErrorMessage(pRes)); if(pRes != NULL) PQclear(pRes); return false; } } PQclear(pRes); return true; }
ResponseCode CResourceFile::Request(HttpRequest* ipoHttpRequest, HttpResponse* ipoHttpResponse) { // HACK - Use http-client-files if possible as the resources directory may have been changed since the resource was loaded. SString strDstFilePath = GetCachedPathFilename(); FILE* file = File::Fopen(strDstFilePath.c_str(), "rb"); if (!file) file = File::Fopen(m_strResourceFileName.c_str(), "rb"); // its a raw page if (file) { // Grab the filesize. Don't use the above method because it doesn't account for a changing // filesize incase of for example an included resource (causing bug #2676) fseek(file, 0, SEEK_END); long lBufferLength = ftell(file); rewind(file); // Allocate and read the entire file // TODO: This is inefficient. char* szBuffer = new char[lBufferLength + 1]; fread(szBuffer, 1, lBufferLength, file); fclose(file); // ipoHttpResponse->oResponseHeaders["content-type"] = "application/octet-stream"; // not really the right mime-type ipoHttpResponse->SetBody(szBuffer, lBufferLength); delete[] szBuffer; return HTTPRESPONSECODE_200_OK; } else { ipoHttpResponse->SetBody("Can't read file!", strlen("Can't read file!")); return HTTPRESPONSECODE_500_INTERNALSERVERERROR; } }
int CLuaMatrixDefs::ToString(lua_State* luaVM) { CLuaMatrix* pMatrix = NULL; CScriptArgReader argStream(luaVM); argStream.ReadUserData(pMatrix); if (!argStream.HasErrors()) { SString string = SString("Matrix: { %.3f, %.3f, %.3f } { %.3f, %.3f, %.3f } { %.3f, %.3f, %.3f } { %.3f, %.3f, %.3f }", pMatrix->vRight.fX, pMatrix->vRight.fY, pMatrix->vRight.fZ, pMatrix->vFront.fX, pMatrix->vFront.fY, pMatrix->vFront.fZ, pMatrix->vUp.fX, pMatrix->vUp.fY, pMatrix->vUp.fZ, pMatrix->vPos.fX, pMatrix->vPos.fY, pMatrix->vPos.fZ); lua_pushstring(luaVM, string.c_str()); return 1; } else { m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); } lua_pushboolean(luaVM, false); return 1; }
// get stream title from metadata and send it as event void CALLBACK MetaSync( HSYNC handle, DWORD channel, DWORD data, void *user ) { CBassAudio* pBassAudio = LockCallbackId( user ); if ( pBassAudio ) { pBassAudio->m_pVars->criticalSection.Lock (); DWORD pSound = pBassAudio->m_pVars->pSound; pBassAudio->m_pVars->criticalSection.Unlock (); const char* szMeta = BASS_ChannelGetTags( pSound, BASS_TAG_META ); if ( szMeta ) { SString strMeta = szMeta; if ( !strMeta.empty () ) { pBassAudio->m_pVars->criticalSection.Lock (); pBassAudio->m_pVars->onClientSoundChangedMetaQueue.push_back ( strMeta ); pBassAudio->m_pVars->criticalSection.Unlock (); } } } UnlockCallbackId(); }
/////////////////////////////////////////////////////////////// // // DelTree // // // /////////////////////////////////////////////////////////////// bool SharedUtil::DelTree ( const SString& strPath, const SString& strInsideHere ) { // Safety: Make sure strPath is inside strInsideHere if ( strPath.ToLower ().substr ( 0, strInsideHere.length () ) != strInsideHere.ToLower () ) { assert ( 0 ); return false; } DWORD dwBufferSize = strPath.length () + 3; char *szBuffer = static_cast < char* > ( alloca ( dwBufferSize ) ); memset ( szBuffer, 0, dwBufferSize ); strncpy ( szBuffer, strPath, strPath.length () ); SHFILEOPSTRUCT sfos; sfos.hwnd = NULL; sfos.wFunc = FO_DELETE; sfos.pFrom = szBuffer; sfos.pTo = NULL; sfos.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; int status = SHFileOperation(&sfos); return status == 0; }
/////////////////////////////////////////////////////////////// // // MyShellExecute // // Returns true if successful // /////////////////////////////////////////////////////////////// static bool MyShellExecute ( bool bBlocking, const SString& strAction, const SString& strInFile, const SString& strInParameters = "", const SString& strDirectory = "", int nShowCmd = SW_SHOWNORMAL ) { SString strFile = strInFile; SString strParameters = strInParameters; if ( strAction == "open" && strFile.BeginsWithI ( "http://" ) && strParameters.empty () ) { strParameters = "url.dll,FileProtocolHandler " + strFile; strFile = "rundll32.exe"; } if ( bBlocking ) { SHELLEXECUTEINFO info; memset( &info, 0, sizeof ( info ) ); info.cbSize = sizeof ( info ); info.fMask = SEE_MASK_NOCLOSEPROCESS; info.lpVerb = strAction; info.lpFile = strFile; info.lpParameters = strParameters; info.lpDirectory = strDirectory; info.nShow = nShowCmd; bool bResult = ShellExecuteExA( &info ) != FALSE; if ( info.hProcess ) { WaitForSingleObject ( info.hProcess, INFINITE ); CloseHandle ( info.hProcess ); } return bResult; } else { int iResult = (int)ShellExecute ( NULL, strAction, strFile, strParameters, strDirectory, nShowCmd ); return iResult > 32; } }
bool CClientWebBrowser::Events_OnResourceFileCheck ( const SString& strPath ) { // If no resource is set, we do not require to verify the file if ( !m_pResource ) return true; auto pFile = g_pClientGame->GetResourceManager ()->GetDownloadableResourceFile ( strPath.ToLower() ); // If we did not download this file, it has been script or user generated, nothing to verify for us if ( pFile == nullptr ) return true; pFile->GenerateClientChecksum (); return pFile->DoesClientAndServerChecksumMatch (); }
//////////////////////////////////////////////////////////////// // // CShaderItem::SetValue // // Set up to 16 floats // //////////////////////////////////////////////////////////////// bool CShaderItem::SetValue ( const SString& strName, const float* pfValues, uint uiCount ) { if ( D3DXHANDLE* phParameter = MapFind ( m_pEffectWrap->m_valueHandleMap, strName.ToUpper () ) ) { // Check if value is changing if ( !m_pShaderInstance->CmpFloatsValue( *phParameter, pfValues, uiCount ) ) { // Check if we need a new shader instance MaybeRenewShaderInstance (); m_pShaderInstance->SetFloatsValue( *phParameter, pfValues, uiCount ); } return true; } return false; }
//////////////////////////////////////////////////////////////// // // CShaderItem::SetValue // // Set one bool // //////////////////////////////////////////////////////////////// bool CShaderItem::SetValue ( const SString& strName, bool bValue ) { if ( D3DXHANDLE* phParameter = MapFind ( m_pEffectWrap->m_valueHandleMap, strName.ToUpper () ) ) { // Check if value is changing if ( !m_pShaderInstance->CmpBoolValue( *phParameter, bValue ) ) { // Check if we need a new shader instance MaybeRenewShaderInstance (); m_pShaderInstance->SetBoolValue( *phParameter, bValue ); } return true; } return false; }
std::string ASE::QueryXfireLight ( void ) { std::stringstream reply; int iJoinedPlayers = m_pPlayerManager->CountJoined (); int iMaxPlayers = m_pMainConfig->GetMaxPlayers (); SString strPlayerCount = SString ( "%d/%d", iJoinedPlayers, iMaxPlayers ); reply << "EYE3"; // game reply << ( unsigned char ) 4; reply << "mta"; // server name reply << ( unsigned char ) ( m_pMainConfig->GetServerName ().length() + 1 ); reply << m_pMainConfig->GetServerName (); // game type reply << ( unsigned char ) ( m_strGameType.length() + 1 ); reply << m_strGameType; // map name with backwardly compatible large player count reply << ( unsigned char ) ( m_strMapName.length() + 1 + strPlayerCount.length () + 1 ); reply << m_strMapName; reply << ( unsigned char ) 0; reply << strPlayerCount; // version std::string temp = MTA_DM_ASE_VERSION; reply << ( unsigned char ) ( temp.length() + 1 ); reply << temp; // passworded reply << ( unsigned char ) ( ( m_pMainConfig->HasPassword () ) ? 1 : 0 ); // players count reply << ( unsigned char ) Min ( iJoinedPlayers, 255 ); // players max reply << ( unsigned char ) Min ( iMaxPlayers, 255 ); return reply.str(); }
void CMoon::WriteScript( SString& strOut_ ) { SString strLine; strLine.Format( "\t$Active = %s;\n", m_bActive ? "true" : "false" ); strOut_ += strLine; strLine.Format( "\t$MeshFile = \"%s\";\n", m_strMeshName.GetData() ); strOut_ += strLine; strLine.Format( "\t$Translation = vec3f( %f, %f, %f );\n", m_vTranslation.X, m_vTranslation.Y, m_vTranslation.Z ); strOut_ += strLine; strLine.Format( "\t$MoonFace = %s;\n", IsMoonFace() ? "true" : "false" ); strOut_ += strLine; strLine.Format( "\t$Color = color4f( %f, %f, %f, %f );\n", m_OriginalColor.A/255.0f, m_OriginalColor.R/255.0f, m_OriginalColor.G/255.0f, m_OriginalColor.B/255.0f ); strOut_ += strLine; strLine.Format( "\t$FillRate = %f;\n", m_fFillRate ); strOut_ += strLine; strLine.Format( "\t$RisingRate = %f;\n", m_fRisingRate ); strOut_ += strLine; strLine.Format( "\t$Pitch = %f;\n", m_fPitch ); strOut_ += strLine; }
bool SOracle::ReadLongRawToFile(SString sTable,SString sLobField,SString sWhere,SString ysFile) { //6.执行一个带有LongRaw的select语句,将LongRaw字段内容保存到文件中 SString sql; sql.sprintf("select %s from %s where %s", sLobField.data(),sTable.data(),sWhere.data()); LOGDEBUG("将LongRaw字段内容保存到文件中:%s",sql.data()); string sSql(sql.data()); string sFile(ysFile.data()); long t_Stmt; OdbRecordSet t_rs; OdbField* pField=new OdbField; pField->Field_Name = sLobField.data(); pField->FileName = sFile; t_rs.paFields.push_back(pField); m_pConn->SqlPrepare(sSql.c_str(),t_Stmt); m_pConn->SqlExecuteWithParam(t_Stmt); m_pConn->DefineColumn(t_Stmt,t_rs); m_pConn->ReadLongRawToFile(t_Stmt,pField->FileName); m_pConn->ClearRecordSets(t_Stmt,t_rs); return true; }
/////////////////////////////////////////////////////////////// // // CClientPerfStatManagerImpl::GetStats // // // /////////////////////////////////////////////////////////////// void CClientPerfStatManagerImpl::GetStats(CClientPerfStatResult* pResult, const SString& strCategory, const SString& strOptions, const SString& strFilter) { pResult->Clear(); if (strCategory == "") { // List all modules pResult->AddColumn("Categories"); for (uint i = 0; i < GetModuleCount(); i++) { CClientPerfStatModule* pModule = GetModuleByIndex(i); pResult->AddRow()[0] = pModule->GetCategoryName(); } pResult->AddRow()[0] = "Help"; return; } // Handle help if (strCategory == "Help") { pResult->AddColumn("Help"); pResult->AddRow()[0] = "Comma separate multiple options"; pResult->AddRow()[0] = "Type h in options and select a category to see help for that category"; return; } // Put options in a map std::map<SString, int> strOptionMap; { std::vector<SString> strParts; strOptions.Split(",", strParts); for (unsigned int i = 0; i < strParts.size(); i++) MapSet(strOptionMap, strParts[i], 1); } // Find module CClientPerfStatModule* pModule = GetModuleByCategoryName(strCategory); if (!pModule) { pResult->AddColumn("Error"); pResult->AddRow()[0] = "Error: Unknown category '" + strCategory + "'"; return; } // Get stats from module pModule->GetStats(pResult, strOptionMap, strFilter); }
std::string escaped_string(SString str) { std::string ret; if (!str) { ret = "<nullptr>"; return ret; } auto const sl = str->slice(); folly::toAppend( "\"", folly::cEscape<std::string>( folly::StringPiece(sl.ptr, sl.len) ), "\"", &ret ); return ret; };
//////////////////////////////////////////////////////////////// // // CFileTextureItem::PostConstruct // // // //////////////////////////////////////////////////////////////// void CFileTextureItem::PostConstruct(CRenderItemManager* pManager, const SString& strFilename, const CPixels* pPixels, bool bMipMaps, uint uiSizeX, uint uiSizeY, ERenderFormat format, ETextureAddress textureAddress, ETextureType textureType, uint uiVolumeDepth) { Super::PostConstruct(pManager); m_uiVolumeDepth = uiVolumeDepth; m_TextureType = textureType; m_TextureAddress = textureAddress; // Initial creation of d3d data if (pPixels) CreateUnderlyingData(pPixels, bMipMaps, format); else if (!strFilename.empty()) CreateUnderlyingData(strFilename, bMipMaps, uiSizeX, uiSizeY, format); else CreateUnderlyingData(bMipMaps, uiSizeX, uiSizeY, format, textureType, uiVolumeDepth); }
int CLuaACLDefs::aclGroupRemoveObject ( lua_State* luaVM ) { // bool aclGroupRemoveObject ( aclgroup theGroup, string theObjectString ) CAccessControlListGroup* pGroup; SString strObject; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pGroup ); argStream.ReadString ( strObject ); if ( !argStream.HasErrors () ) { // Figure out what type of object this is const char* szObjectAfterDot = strObject; CAccessControlListGroupObject::EObjectType eType; if ( StringBeginsWith ( strObject, "resource." ) ) { eType = CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE; szObjectAfterDot += 9; } else if ( StringBeginsWith ( strObject, "user." ) ) { eType = CAccessControlListGroupObject::OBJECT_TYPE_USER; szObjectAfterDot += 5; } else { lua_pushboolean ( luaVM, false ); return 1; } // Remove it if ( pGroup->RemoveObject ( szObjectAfterDot, eType ) ) { // Return success CLogger::LogPrintf ( "ACL: %s: Object '%s' removed from group '%s'\n", GetResourceName ( luaVM ), strObject.c_str (), pGroup->GetGroupName () ); lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
// See code:BINDER_SPACE::AssemblyBinder::GetAssembly for info on fNgenExplicitBind // and fExplicitBindToNativeImage, and see code:CEECompileInfo::LoadAssemblyByPath // for an example of how they're used. HRESULT CLRPrivBinderCoreCLR::Bind(SString &assemblyDisplayName, LPCWSTR wszCodeBase, PEAssembly *pParentAssembly, BOOL fNgenExplicitBind, BOOL fExplicitBindToNativeImage, ICLRPrivAssembly **ppAssembly) { HRESULT hr = S_OK; VALIDATE_ARG_RET(ppAssembly != NULL); AssemblyName assemblyName; ReleaseHolder<AssemblyName> pAssemblyName; if (!assemblyDisplayName.IsEmpty()) { // AssemblyDisplayName can be empty if wszCodeBase is specified. SAFE_NEW(pAssemblyName, AssemblyName); IF_FAIL_GO(pAssemblyName->Init(assemblyDisplayName)); } EX_TRY { ReleaseHolder<BINDER_SPACE::Assembly> pAsm; hr = AssemblyBinder::BindAssembly(&m_appContext, pAssemblyName, wszCodeBase, pParentAssembly, fNgenExplicitBind, fExplicitBindToNativeImage, false, // excludeAppPaths &pAsm); if(SUCCEEDED(hr)) { _ASSERTE(pAsm != NULL); pAsm->SetBinder(this); *ppAssembly = pAsm.Extract(); } } EX_CATCH_HRESULT(hr); Exit: return hr; }
// // Direct players to info about trouble // void SharedUtil::BrowseToSolution ( const SString& strType, bool bAskQuestion, bool bTerminateProcess, bool bDoOnExit, const SString& strMessageBoxMessage ) { AddReportLog ( 3200, SString ( "Trouble %s", *strType ) ); // Put args into a string and save in the registry CArgMap argMap; argMap.Set ( "type", strType.SplitLeft ( ";" ) ); argMap.Set ( "bAskQuestion", bAskQuestion ); argMap.Set ( "message", strMessageBoxMessage ); SetApplicationSetting ( "pending-browse-to-solution", argMap.ToString () ); // Do it now if required if ( !bDoOnExit ) ProcessPendingBrowseToSolution (); // Exit if required if ( bTerminateProcess ) TerminateProcess ( GetCurrentProcess (), 1 ); }
bool cXMLLoader::iSetToAttribute(SString strAttributeName) { if (this->m_pRoot == nullptr) { this->_PushError(_SSTR("Error: The file is empty")); return false; } if (strAttributeName.empty()) { this->_PushError(_SSTR("Error: The attribute name is empty")); return false; } if (this->m_pCurrentNode == nullptr) { this->_PushError(_SSTR("Error: The current node pointer is empty")); return false; } if (this->m_pCurrentNode->data.Attributes.empty()) { this->_PushError(_SSTR("Error: The current node attribute list is empty")); return false; } if ((sint) (this->m_pCurrentAttribute->first.find(::gloTToW(strAttributeName))) == 0) { return true; } list<_spair<SStringW, SStringW>>::iterator pItem = this->m_pCurrentNode->data.Attributes.begin(); while (pItem != this->m_pCurrentNode->data.Attributes.end()) { if ((sint) (pItem->first.find(::gloTToW(strAttributeName))) == 0) { break; } pItem++; } if (pItem == this->m_pCurrentNode->data.Attributes.end()) { this->_PushError(_SSTR("Error: Can't fine attribute ") + strAttributeName + _SSTR(" in node ") + ::gloWToT(this->m_pCurrentNode->data.Name)); return false; } this->m_pCurrentAttribute = pItem; return true; }
/** * Transform this Ebwt into the original string in linear time by using * the LF mapping to walk backwards starting at the row correpsonding * to the end of the string. The result is written to s. The Ebwt * must be in memory. */ void Ebwt::restore(SString<char>& s) const { assert(isInMemory()); s.resize(this->_eh._len); uint32_t jumps = 0; uint32_t i = this->_eh._len; // should point to final SA elt (starting with '$') SideLocus l(i, this->_eh, this->ebwt()); while(i != _zOff) { assert_lt(jumps, this->_eh._len); //if(_verbose) cout << "restore: i: " << i << endl; // Not a marked row; go back a char in the original string uint32_t newi = mapLF(l ASSERT_ONLY(, false)); assert_neq(newi, i); s[this->_eh._len - jumps - 1] = rowL(l); i = newi; l.initFromRow(i, this->_eh, this->ebwt()); jumps++; } assert_eq(jumps, this->_eh._len); }
bool CAccountManager::SetAccountData( CAccount* pAccount, const char* szKey, const SString& strValue, int iType ) { if ( iType != LUA_TSTRING && iType != LUA_TNUMBER && iType != LUA_TBOOLEAN && iType != LUA_TNIL ) return false; //Get the user ID int iUserID = pAccount->GetID(); SString strKey = szKey; //Does the user want to delete the data? if ( strValue == "false" && iType == LUA_TBOOLEAN ) { m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM userdata WHERE userid=? AND key=?", SQLITE_INTEGER, iUserID, SQLITE_TEXT, strKey.c_str () ); return true; } m_pDatabaseManager->Execf ( m_hDbConnection, "INSERT OR IGNORE INTO userdata (userid, key, value, type) VALUES(?,?,?,?)", SQLITE_INTEGER, pAccount->GetID (), SQLITE_TEXT, strKey.c_str (), SQLITE_TEXT, strValue.c_str (), SQLITE_INTEGER, iType ); m_pDatabaseManager->QueryWithCallbackf ( m_hDbConnection, StaticDbCallback, this, "UPDATE userdata SET value=?, type=? WHERE userid=? AND key=?", SQLITE_TEXT, strValue.c_str (), SQLITE_INTEGER, iType, SQLITE_INTEGER, iUserID, SQLITE_TEXT, strKey.c_str () ); return true; }
void CScriptDebugging::LogError ( SString strFile, int iLine, SString strMsg ) { SString strText = SString ( "ERROR: %s:%d: %s", strFile.c_str (), iLine, strMsg.c_str () ); if ( !m_bTriggeringOnDebugMessage ) { m_bTriggeringOnDebugMessage = true; // Prepare onDebugMessage CLuaArguments Arguments; Arguments.PushString ( strMsg.c_str ( ) ); Arguments.PushNumber ( 1 ); // Push the file name (if any) if ( strFile.length ( ) > 0 ) Arguments.PushString ( strFile.c_str ( ) ); else Arguments.PushNil ( ); // Push the line (if any) if ( iLine > -1 ) Arguments.PushNumber ( iLine ); else Arguments.PushNil ( ); // Call onDebugMessage g_pGame->GetMapManager ( )->GetRootElement ( )->CallEvent ( "onDebugMessage", Arguments ); m_bTriggeringOnDebugMessage = false; } // Log it to the file if enough level if ( m_uiLogFileLevel >= 1 ) { PrintLog ( strText ); } // Log to console CLogger::LogPrintf( "%s\n", strText.c_str () ); // Tell the players Broadcast ( CDebugEchoPacket ( strText, 1, 255, 255, 255 ), 1 ); }