FString LoadShaderSourceFile(const TCHAR* Filename) { FString strFileContent; FString strShaderFilename = FStringUtil::Sprintf(TEXT("%s%s%s"), appBaseDir(), appShaderDir(), Filename); if( !FStringUtil::EndWith( strShaderFilename, FString(TEXT(".vsf")) ) ) { strShaderFilename += TEXT(".vsf"); } map<FString, FString>::iterator it = GShaderFileCache.find(strShaderFilename.c_str()); if( it == GShaderFileCache.end() ) { appLoadFileToString(strFileContent, strShaderFilename.c_str()); GShaderFileCache[strShaderFilename] = strFileContent; } else { strFileContent = it->second; } return strFileContent; }
INT FFileManagerWindows::UncompressedFileSize( const TCHAR* Filename ) { // default to not using the uncompressed file size INT Result = -1; // check for the presence of a .uncompressed_size manifest file which mirrors the Filename // if it exists, then the file was fully compressed, so we get the original uncompressed size for it FString UnCompressedSizeFilename = FString(Filename) + FString(TEXT(".uncompressed_size")); if( FileSize(*UnCompressedSizeFilename) != -1 ) { FString SizeString; appLoadFileToString(SizeString, *UnCompressedSizeFilename); check(SizeString.Len()); // get the uncompressed size from the file Result = appAtoi(*SizeString); } return Result; }
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); }