//----------------------------------------------------------------------------- // Used to detect where steam is running from //----------------------------------------------------------------------------- static bool DetectSteamPath( char *pFileName, int nBufLen ) { *pFileName = 0; DWORD nLen; // First check to see if there's an active process HKEY hKey; LONG hResult = RegOpenKey( HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", &hKey ); if ( hResult == ERROR_SUCCESS ) { nLen = (DWORD)nBufLen; hResult = RegQueryValueEx( hKey, "SteamClientDll", NULL, NULL, (LPBYTE)pFileName, &nLen ); RegCloseKey( hKey ); if ( hResult == ERROR_SUCCESS ) { // In this case, we queried the key properly. Strip off the steamclient.dll name // to make a good full path to steam.exe size_t nUsed = StripFileName( pFileName ); strncpy( &pFileName[nUsed], "steam.exe", nBufLen - nUsed ); return true; } } // If not, then get the default install location hResult = RegOpenKey( HKEY_CURRENT_USER, "Software\\Valve\\Steam", &hKey ); if ( hResult != ERROR_SUCCESS ) return false; nLen = (DWORD)nBufLen; hResult = RegQueryValueEx( hKey, "SteamExe", NULL, NULL, (LPBYTE)pFileName, &nLen ); RegCloseKey( hKey ); return ( hResult == ERROR_SUCCESS && nLen != 0 ); }
virtual void GenerateShaderLib() { const UINT numSrcFiles = config.srcFiles.Num(); if( !numSrcFiles ) { Msgf("No input files are specified. Quitting..."); return; } Msgf("Generating shader library..."); ParseResults parseResults; for( UINT iSrcFile = 0; iSrcFile < numSrcFiles; iSrcFile++ ) { const OSPathName & srcFileName( config.srcFiles[ iSrcFile ] ); ParseFileInput input; input.pathToSrcFile = srcFileName; ParseFileOutput & output = parseResults.parsedFiles.Add(); output.fileData.name = config.outputFolderHLSL; output.fileData.name += StripFileName(srcFileName); output.fileData.pureFileName = GetPureFileName(srcFileName); ParseFile( input, output ); } Translate( config, parseResults ); }
//----------------------------------------------------------------------------- // Copies test files into position //----------------------------------------------------------------------------- static bool CopyFilesIntoPosition( const char *pSteamPath ) { // Create a file that makes steam not delete different DLLs char pSteamRoot[MAX_PATH]; strncpy( pSteamRoot, pSteamPath, sizeof(pSteamRoot) ); StripFileName( pSteamRoot ); char pSrcRoot[MAX_PATH]; if ( !::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), pSrcRoot, sizeof(pSrcRoot) ) ) { printf( "Unable to find rpt launch path!\n" ); return false; } StripFileName( pSrcRoot ); return CopyFilesRecursively( pSrcRoot, pSteamRoot ); }
void EditFileName( void ) { char str[256]; strncpy( str, currentFile.name, 256 ); StripFileName( str ); renameWindowShowing = TRUE; returnFromRename = FALSE; ActivateKeyboard( str, FILENAME_LENGTH, &ReturnFromRenameKeyboard ); }
//----------------------------------------------------------------------------- // Launches new steam process //----------------------------------------------------------------------------- static bool LaunchNewSteamProcess( const char *pSteamPath ) { // Create a file that makes steam not delete different DLLs char pCfgPath[MAX_PATH]; strncpy( pCfgPath, pSteamPath, sizeof(pCfgPath) ); size_t nUsed = StripFileName( pCfgPath ); strncpy( &pCfgPath[nUsed], "steam.cfg", sizeof(pCfgPath) - nUsed ); FILE* fp = fopen( pCfgPath, "wt" ); if ( !fp ) { printf( "rpt: Unable to relaunch steam! Aborting...\n" ); return false; } fprintf( fp, "MinFootprintAutoRefresh = disable\n" ); fclose( fp ); // Launch a new instance of steam DWORD nNewPID = LaunchSteam( pSteamPath, "" ); // Wait for the new process to start. // Wait for at least 30 seconds. If it doesn't start by that time, // stop what we're doing. DWORD nStartTime = GetTickCount(); DWORD nTestTime = 30; while ( GetActiveSteamPID( ) != nNewPID ) { Sleep( 1000 ); DWORD dt = ( GetTickCount() - nStartTime ) / 1000; if ( dt <= nTestTime ) continue; TerminateSteamProcess( nNewPID ); DeleteCfgFile( pCfgPath ); printf( "rpt: Unable to launch new steam process!" ); return false; } DeleteCfgFile( pCfgPath ); return true; }
//============================== // BitmapFontLocal::Load bool BitmapFontLocal::Load( char const * languagePackageName, char const * fontInfoFileName ) { OvrApkFile languagePackageFile( ovr_OpenOtherApplicationPackage( languagePackageName ) ); if ( !FontInfo.Load( languagePackageFile, fontInfoFileName ) ) { return false; } // strip any path from the image file name path and prepend the path from the .fnt file -- i.e. always // require them to be loaded from the same directory. String baseName = FontInfo.ImageFileName.GetFilename(); LOG( "fontInfoFileName = %s", fontInfoFileName ); LOG( "image baseName = %s", baseName.ToCStr() ); char imagePath[512]; StripFileName( fontInfoFileName, imagePath, sizeof( imagePath ) ); LOG( "imagePath = %s", imagePath ); char imageFileName[512]; StripPath( fontInfoFileName, imageFileName, sizeof( imageFileName ) ); LOG( "imageFileName = %s", imageFileName ); AppendPath( imagePath, sizeof( imagePath ), baseName.ToCStr() ); if ( !LoadImage( languagePackageFile, imagePath ) ) { return false; } // create the shaders for font rendering if not already created if ( FontProgram.vertexShader == 0 || FontProgram.fragmentShader == 0 ) { FontProgram = BuildProgram( FontSingleTextureVertexShaderSrc, SDFFontFragmentShaderSrc );//SingleTextureFragmentShaderSrc ); } return true; }
//------------ // void MoveAFile(char* sourceDir, char* destDir, char* sourceFile, dword attr) { bool fileAlreadyExists; char targetDir[500]; char currentFileName[256], baseFileName[256], title1[50], title2[50], str1[256], str2[256], fileName[256], counter[6]; int fileIncrement; // A counter used in case we need to append a number to an already existing file name. appendToLogfile("MoveAFile: Started.", WARNING); // If we try to move a file and there is already an existing file in the target directory // with the same name, we will append an incrementing counter to the file name. (eg. news-1.rec news-23.rec) fileAlreadyExists = FALSE; // Flag to indicate that the renamed file already exists. fileIncrement = 0; // Counter in case we need to append a number to an already existing file name. if (attr != ATTR_FOLDER) { strncpy( currentFileName, sourceFile, 256 ); // Copy the current filename strncpy( fileName, sourceFile, 256 ); // Copy the current filename strncpy( baseFileName, sourceFile, 256 ); // Copy the current filename StripFileName( baseFileName ); // Strip off the ".rec" strncpy( fileName, baseFileName, 256 ); // Copy the stripped off filename in case we need to rename on a move. strcat( fileName, REC_STRING ); // Append ".rec" to the base filename } // Perform check that the Move routine is available for this firmware. #ifdef WIN32 #else if (!TAP_Hdd_Move_Available()) { ShowMessageWin( rgn, "Move NOT available.", "This firmware does not support", "the move function via Archive.", 400 ); returnFromMove = TRUE; // Force a closer of the Move window, and refresh the list. return; } #endif appendToLogfile("MoveAFile: Creating target filename.", WARNING); // Create the fully qualified target directory name. // // Start with the Source Directory strcpy(targetDir, sourceDir); // Add the intermediate "/" strcat(targetDir, "/" ); // Add the target directory. strcat(targetDir, destDir); // Check in the target directory to make sure a file with the same name doesn't already exists. // // Change to the target directory. appendStringToLogfile("MoveAFile: Changing to targetdir: %s.",targetDir, WARNING); GotoPath( targetDir ); // Check for the same file. appendStringToLogfile("MoveAFile: Calling TAP_Hdd_Exist for:%s",sourceFile, WARNING); fileAlreadyExists = TAP_Hdd_Exist(sourceFile); // If we're moving a file and the target already exists, try to rename it - if the config option #28 has been set to allow rename.. while ((fileAlreadyExists) && (fileIncrement < 99999) && (attr != ATTR_FOLDER) && (RenameOnMoveOption!=3)) { fileIncrement++; // Increase the counter for the number to append to the filename. appendIntToLogfile("MoveAFile: fileAlreadyExists loop:%d",fileIncrement, WARNING); sprintf(counter, "-%d", fileIncrement); // Create the counter text strncpy( fileName, baseFileName, 256); // Copy back the original filename strcat( fileName, counter); // Append the counter text to the filename strcat( fileName, REC_STRING ); // Append the ".rec" to the end. appendStringToLogfile("MoveAFile: fileAlreadyExists loop calling TAP_Hdd_Exist for: %s", fileName, WARNING); fileAlreadyExists = TAP_Hdd_Exist(fileName); // Check if the file exists. appendToLogfile("MoveAFile: fileAlreadyExists loop TAP_Hdd_Exist finished", WARNING); } // Return to the original directory. appendStringToLogfile("MoveAFile: Changing to sourceDir: %s.",sourceDir, WARNING); GotoPath( sourceDir ); // Set up appropriate text strings for message windows, depending on whether it's a file or folder. switch (attr) { case ATTR_FOLDER: TAP_SPrint(title1, "Folder Move Failed."); TAP_SPrint(title2, ""); TAP_SPrint(str1, "Same folder already exists:"); TAP_SPrint(str2, ""); break; default: TAP_SPrint(title1, "File Move Failed."); TAP_SPrint(title2, "File Move Conflict."); TAP_SPrint(str1, "Same file already exists."); TAP_SPrint(str2, "Same file already exists. Rename to:"); break; } // Copy source and destination information to Global variables so that they are available for the actual move routine. strncpy( GlbSourceFile, sourceFile, 256 ); // Copy the source filename strncpy( GlbSourceDir, sourceDir, 256 ); // Copy the source directory strncpy( GlbTargetDir, targetDir, 256 ); // Copy the target directory // If the target file already exists in the target directory we can't move. if (fileAlreadyExists) { ShowMessageWin( rgn, title1, str1, sourceFile, 400 ); fileMoved = FALSE; returnFromMove = FALSE; // Don't close the Move window to give user a chance to choose a different folder. return; // Jump out of this routine as we can't do the move. } // Check if we needed to rename the file in the target directory. if (fileIncrement > 0) { strncpy( GlbRenamedFile, fileName, 256 ); // Copy the renamed filename into the Global variable // Check the config option #28 to see if the Rename On Move requires a confirmation or not. if (RenameOnMoveOption == 0) // Need to display a confirmation panel. { DisplayYesNoWindow(title2, str2, fileName, "Yes", "No", 1, &ReturnFromMoveRenameYesNo ); fileMoved = FALSE; returnFromMove = FALSE; // Don't close the Move window until after the Yes/No window. return; // Jump out of this routine as Move will be done after Yes/No window. } else // Otherwise call routine as if we said "Yes" on the confirmation window. { ReturnFromMoveRenameYesNo( TRUE ); return; // Jump out of this routine as we've already done the move in the ReturnFromMoveRenameYesNo routine. } } // Call the routine to perform the actual move. PerformMove(); appendToLogfile("MoveAFile: Finished.", WARNING); }