コード例 #1
0
ファイル: ShaderCompiler.cpp プロジェクト: xukunn1226/VRI3
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;
}
コード例 #2
0
/**
 * Converts passed in filename to use an absolute path.
 *
 * @param	Filename	filename to convert to use an absolute path, safe to pass in already using absolute path
 * 
 * @return	filename using absolute path
 */
FString FFileManagerWindows::ConvertToAbsolutePath( const TCHAR* Filename )
{
	FString AbsolutePath = Filename;

	// See whether it is a relative path.
	if( AbsolutePath.StartsWith( TEXT("..") ) )
	{
		// And if that's the case append the base dir.
		AbsolutePath = FString(appBaseDir()) + AbsolutePath;
	}

	return AbsolutePath;
}
コード例 #3
0
void USetupDefinition::Init()
{
	guard(USetupDefinition::Init);

	// Figure out source folder.
	SrcPath = appBaseDir();
	if( SrcPath.Right(1)==PATH_SEPARATOR )
		SrcPath = SrcPath.LeftChop( 1 );
	while( SrcPath.Len() && SrcPath.Right(1)!=PATH_SEPARATOR )
		SrcPath = SrcPath.LeftChop( 1 );
	if( SrcPath.Len() )
		SrcPath = SrcPath.LeftChop( 1 );

	// See if installing a packed .umod file.
	FString Token;
	const TCHAR* Cmd = appCmdLine();
	ParseToken( Cmd, Token, 0 );
	if( Token==TEXT("install") || (Token==TEXT("") && MasterProduct==TEXT("")) )
	{
		// Installing.
		if( Token==TEXT("install") )
		{
			// Verify that the specified module exists.
			ParseToken( Cmd, Token, 0 );
			GFileManager = new FFileManagerArc(GFileManager,*Token,1);
			GFileManager->Init(0);
			Token = TEXT("");
			ParseToken( Cmd, Token, 0 );

			// Reload config from the new filer manager.
			GConfig->Flush(1,MANIFEST_FILE MANIFEST_EXT);
			LoadConfig();
			LoadLocalized();
		}

		// Detach configuration file so we can modify it locally.
		GConfig->Detach( *ConfigFile );
		Manifest = 1;
	}
	else if( Token==TEXT("reallyuninstall") )
	{
		// Running uninstaller from temp folder.
		ParseToken( Cmd, Product, 0 );
		Parse( appCmdLine(), TEXT("PATH="), DestPath );
		if( DestPath.Right(1)==PATH_SEPARATOR )
			DestPath = DestPath.LeftChop( 1 );
		while( DestPath.Len() && DestPath.Right(1)!=PATH_SEPARATOR )
			DestPath = DestPath.LeftChop( 1 );
		Uninstalling = 1;
	}
	else if( Token==TEXT("uninstall") || (Token==TEXT("") && MasterProduct!=TEXT("")) )
	{
		// Running uninstaller for the first time.
		NoRun = 1;
		if( Token==TEXT("uninstall") )
			ParseToken( Cmd, Product, 0 );
		else
			Product = MasterProduct;
		PerformUninstallCopy();
	}
	else appErrorf(TEXT("Setup: Unknown disposition"));

	// Validate everything.
	if( !appAtoi(*Version) && !Uninstalling && !NoRun )
		appErrorf( TEXT("Setup: Missing version number") );

	// Determine whether known to be installed.
	Exists
	=	GetRegisteredProductFolder( Product, RegistryFolder )
	&&	GFileManager->FileSize(*(RegistryFolder*TEXT("System")*SETUP_INI))>0;

	// If this is a mod, find required product's path.
	FolderExists = Exists;
	if( !Exists && !Uninstalling && !NoRun )
	{
		FString RequiredProduct, FindFolder;
		for( TArray<FString>::TIterator It(Requires); It; ++It )
			if(	GConfig->GetString(**It, TEXT("Product"), RequiredProduct, *ConfigFile) )
			{
				if( RequiredProduct==TEXT("Unreal Tournament") )
					RequiredProduct = TEXT("UnrealTournament");
				if( GetRegisteredProductFolder(RequiredProduct, FindFolder)
				&&	GFileManager->FileSize(*(FindFolder*TEXT("System")*SETUP_INI)) )
				{
					RegistryFolder = FindFolder;
					FolderExists   = 1;
					break;
				}
			}
	}

	// Figure language.
	FString Str;
	if( GConfig->GetString(TEXT("Engine.Engine"),TEXT("Language"),Str,*(RegistryFolder*TEXT("System\\Default.ini"))) )
		UObject::SetLanguage( *Str );
	LanguageChange();

	unguard;
}
コード例 #4
0
FString FFileManagerWindows::GetCurrentDirectory()
{
	return appBaseDir();
}
コード例 #5
0
UBOOL FFileManagerWindows::SetDefaultDirectory()
{
	return SetCurrentDirectoryW(appBaseDir())!=0;
}
コード例 #6
0
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);
}