/** * Sends a command to the database proxy. * * @param Cmd The command to be sent. */ UBOOL ExecuteDBProxyCommand(FSocket *Socket, const TCHAR* Cmd) { check(Socket); check(Cmd); INT CmdStrLength = appStrlen(Cmd); INT BytesSent = 0; // add 1 so we also send NULL ++CmdStrLength; TCHAR *SendBuf = (TCHAR*)appMalloc(CmdStrLength * sizeof(TCHAR)); // convert to network byte ordering. This is important for running on the ps3 and xenon for(INT BufIndex = 0; BufIndex < CmdStrLength; ++BufIndex) { SendBuf[BufIndex] = htons(Cmd[BufIndex]); } UBOOL bRet = Socket->Send((BYTE*)SendBuf, CmdStrLength * sizeof(TCHAR), BytesSent); appFree(SendBuf); return bRet; }
void DConsoleWindow::AddString( lpctstr lpszString, dword dwParam ) { if( m_apLines==NULL ) return; TCHAR szBuf[256]; int dwPos=0; int dwBufPos=0; int dwSize = appStrlen( lpszString ); while( dwPos<dwSize ) { if( lpszString[dwPos]=='\n' ) {// new line and.. add a line! szBuf[dwBufPos] = 0; AddLine( szBuf ); dwBufPos=0; } else { szBuf[dwBufPos] = lpszString[dwPos]; dwBufPos++; } dwPos++; } if( dwBufPos>0 ) { szBuf[dwBufPos] = 0; AddLine( szBuf ); } VisualSort(); }
/** * Starts writing stats data to disk */ void FStatNotifyProvider_BinaryFile::StartWritingStatsFile() { // NOTE: Make sure to update BinaryStatFileVersion if you change serialization behavior or data formats! if( File != NULL ) { debugf( TEXT( "Stats System: Can't start capturing stats because a capture is already in progress." ) ); return; } // Create the file if( !CreateOutputFile() ) { debugf( TEXT( "Stats System: Couldn't create output file for stat capture." ) ); return; } check( File != NULL ); // We're expecting the files to be written out in big-endian since that's what StatsViewer wants #if !( NO_BYTE_ORDER_SERIALIZE && !WANTS_XBOX_BYTE_SWAPPING ) File->SetByteSwapping( TRUE ); #endif debugf( TEXT( "Stats System: Capturing stat data to disk." ) ); FArchive& OutputFile = *File; // Write header { // NOTE: If you change the binary stats file format, update this version number as well // as the version number in StatsViewerMisc.cpp! /* const */ DWORD BinaryStatFileVersion = 3; // Header tag (ASCII) const ANSICHAR* HeaderTagString = "USTATS"; const INT HeaderTagLength = appStrlen( HeaderTagString ); for( INT CharIndex = 0; CharIndex < HeaderTagLength; ++CharIndex ) { BYTE CurCharByte = ( BYTE )HeaderTagString[ CharIndex ]; OutputFile << CurCharByte; } // Version info OutputFile << BinaryStatFileVersion; // Number of seconds for each cycle value FLOAT SecondsPerCycleAsFloat = ( FLOAT )GSecondsPerCycle; OutputFile << SecondsPerCycleAsFloat; } // Force scoped cycle stats to be enabled. GForceEnableScopedCycleStats++; }
/** * Builds a human readable name from the commandlets name * * @param Commandlet the commandlet to mangle the name of */ static FString GetCommandletName(UCommandlet* Commandlet) { // Don't print out the default portion of the name static INT SkipLen = appStrlen(TEXT("Default__")); FString Name(*Commandlet->GetName() + SkipLen); // Strip off everything past the friendly name INT Index = Name.InStr(TEXT("Commandlet")); if (Index != -1) { Name = Name.Left(Index); } // Get the code package this commandlet is contained in UObject* Outer = Commandlet->GetOutermost(); // Build Package.Commandlet as the name FString FullName = Outer->GetName(); FullName += TEXT("."); FullName += Name; return FullName; }
void FFileManagerWindows::Init(UBOOL Startup) { // a shipped PC game will always run as if installed #if SHIPPING_PC_GAME && !UDK // shipping PC game bIsRunningInstalled = TRUE; #else // for development, use a commandline param (-installed) bIsRunningInstalled = ParseParam(appCmdLine(),TEXT("installed")); #endif // Allow overriding use of My Documents folder with -NOHOMEDIR if( ParseParam(appCmdLine(),TEXT("NOHOMEDIR") ) ) { bIsRunningInstalled = FALSE; } if (bIsRunningInstalled) { debugf( TEXT( " ... running in INSTALLED mode" ) ); TCHAR UserPath[MAX_PATH]; // get the My Documents directory HRESULT Ret = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, UserPath); // get the per-game directory name to use inside the My Documents directory FString DefaultIniContents; // load the DefaultEngine.ini config file into a string for later parsing (ConvertAbsolutePathToUserPath will use // original location since WindowsUserDir hasn't been set yet) // can't use GDefaultEngineIni, because that may be something that doesn't have the tag if (!appLoadFileToString(DefaultIniContents, *(appGameConfigDir() + TEXT("DefaultEngine.ini")), this)) { // appMsgf won't write to a log if GWarn is NULL, which it should be at this point appMsgf(AMT_OK, TEXT("Failed to find default engine .ini file to retrieve My Documents subdirectory to use. Force quitting.")); exit(1); return; } #define MYDOC_KEY_NAME TEXT("MyDocumentsSubDirName=") // find special key in the .ini file (can't use GConfig because it can't be used yet until after filemanager is made) INT KeyLocation = DefaultIniContents.InStr(MYDOC_KEY_NAME, FALSE, TRUE); if (KeyLocation == INDEX_NONE) { // appMsgf won't write to a log if GWarn is NULL, which it should be at this point appMsgf(AMT_OK, TEXT("Failed to find %s key in DefaultEngine.ini. Force quitting."), MYDOC_KEY_NAME); exit(1); return; } // skip over the key to get the value (skip key and = sign) and everything after it FString ValueAndLeftover = DefaultIniContents.Mid(KeyLocation + appStrlen(MYDOC_KEY_NAME)); // now chop off this string at an end of line TArray<FString> Tokens; ValueAndLeftover.ParseIntoArray(&Tokens, TEXT("\r\n"), TRUE); // make the base user dir path WindowsUserDir = FString(UserPath) + TEXT("\\My Games\\") + Tokens(0) #if DEMOVERSION + TEXT(" Demo") #endif + TEXT("\\"); // find out our executable path WindowsRootDir = appBaseDir(); // strip off the Binaries directory WindowsRootDir = WindowsRootDir.Left(WindowsRootDir.InStr(TEXT("\\Binaries\\"), TRUE, TRUE) + 1); // Now that the root directory has been set, create directories at startup. // Note this must come after the above because MakeDirectory calls // ConvertAbsolutePathToUserPath which uses WindowsRootDir and WindowsUserDir. #define DIRSTOCREATATSTARTUP_KEY_NAME TEXT("DirsToCreateAtStartup=") INT FindStartPos = INDEX_NONE; while ( TRUE ) { // find special key in the .ini file (can't use GConfig because it can't be used yet until after filemanager is made) const INT KeyLocation = DefaultIniContents.InStr(DIRSTOCREATATSTARTUP_KEY_NAME, FALSE, TRUE, FindStartPos); if (KeyLocation == INDEX_NONE) { break; } // Advance the find pos because we're doing a multi find. FindStartPos = KeyLocation + appStrlen(DIRSTOCREATATSTARTUP_KEY_NAME); // skip over the key to get the value (skip key and = sign) and everything after it FString ValueAndLeftover = DefaultIniContents.Mid(KeyLocation + appStrlen(DIRSTOCREATATSTARTUP_KEY_NAME)); // now chop off this string at an end of line TArray<FString> Tokens; ValueAndLeftover.ParseIntoArray(&Tokens, TEXT("\r\n"), TRUE); // Create the directory. MakeDirectory( *Tokens(0), TRUE ); } } FFileManagerGeneric::Init(Startup); }