本文整理汇总了C#中FileReference.IsUnderDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# FileReference.IsUnderDirectory方法的具体用法?C# FileReference.IsUnderDirectory怎么用?C# FileReference.IsUnderDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReference
的用法示例。
在下文中一共展示了FileReference.IsUnderDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindShortestRelativePath
/// <summary>
/// Find the shortest relative path of the given file from a set of base directories.
/// </summary>
/// <param name="File">Full path to a file</param>
/// <param name="RebaseDirs">Possible base directories</param>
/// <returns>The shortest relative path, or null if the file is not under any of them</returns>
public static string FindShortestRelativePath(FileReference File, IEnumerable<DirectoryReference> RebaseDirs)
{
string RelativePath = null;
foreach(DirectoryReference RebaseDir in RebaseDirs)
{
if(File.IsUnderDirectory(RebaseDir))
{
string NewRelativePath = File.MakeRelativeTo(RebaseDir);
if(RelativePath == null || NewRelativePath.Length < RelativePath.Length)
{
RelativePath = NewRelativePath;
}
}
}
return RelativePath;
}
示例2: ExecuteBuild
public override void ExecuteBuild()
{
// Get the plugin filename
string PluginParam = ParseParamValue("Plugin");
if(PluginParam == null)
{
throw new AutomationException("Missing -Plugin=... argument");
}
// Check it exists
FileReference PluginFile = new FileReference(PluginParam);
if (!PluginFile.Exists())
{
throw new AutomationException("Plugin '{0}' not found", PluginFile.FullName);
}
// Get the output directory
string PackageParam = ParseParamValue("Package");
if (PackageParam == null)
{
throw new AutomationException("Missing -Package=... argument");
}
// Make sure the packaging directory is valid
DirectoryReference PackageDir = new DirectoryReference(PackageParam);
if (PluginFile.IsUnderDirectory(PackageDir))
{
throw new AutomationException("Packaged plugin output directory must be different to source");
}
if (PackageDir.IsUnderDirectory(DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine")))
{
throw new AutomationException("Output directory for packaged plugin must be outside engine directory");
}
// Clear the output directory of existing stuff
if (PackageDir.Exists())
{
CommandUtils.DeleteDirectoryContents(PackageDir.FullName);
}
else
{
PackageDir.CreateDirectory();
}
// Create a placeholder FilterPlugin.ini with instructions on how to use it
FileReference SourceFilterFile = FileReference.Combine(PluginFile.Directory, "Config", "FilterPlugin.ini");
if (!SourceFilterFile.Exists())
{
List<string> Lines = new List<string>();
Lines.Add("[FilterPlugin]");
Lines.Add("; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and");
Lines.Add("; may include \"...\", \"*\", and \"?\" wildcards to match directories, files, and individual characters respectively.");
Lines.Add(";");
Lines.Add("; Examples:");
Lines.Add("; /README.txt");
Lines.Add("; /Extras/...");
Lines.Add("; /Binaries/ThirdParty/*.dll");
SourceFilterFile.Directory.CreateDirectory();
CommandUtils.WriteAllLines_NoExceptions(SourceFilterFile.FullName, Lines.ToArray());
}
// Create a host project for the plugin. For script generator plugins, we need to have UHT be able to load it, which can only happen if it's enabled in a project.
FileReference HostProjectFile = FileReference.Combine(PackageDir, "HostProject", "HostProject.uproject");
FileReference HostProjectPluginFile = CreateHostProject(HostProjectFile, PluginFile);
// Read the plugin
CommandUtils.Log("Reading plugin from {0}...", HostProjectPluginFile);
PluginDescriptor Plugin = PluginDescriptor.FromFile(HostProjectPluginFile, false);
// Compile the plugin for all the target platforms
List<UnrealTargetPlatform> HostPlatforms = ParseParam("NoHostPlatform")? new List<UnrealTargetPlatform>() : new List<UnrealTargetPlatform> { BuildHostPlatform.Current.Platform };
List<UnrealTargetPlatform> TargetPlatforms = GetTargetPlatforms(this, BuildHostPlatform.Current.Platform).Where(x => IsCodeTargetPlatform(BuildHostPlatform.Current.Platform, x)).ToList();
FileReference[] BuildProducts = CompilePlugin(HostProjectFile, HostProjectPluginFile, Plugin, HostPlatforms, TargetPlatforms, "");
// Package up the final plugin data
PackagePlugin(HostProjectPluginFile, BuildProducts, PackageDir);
// Remove the host project
if(!ParseParam("NoDeleteHostProject"))
{
CommandUtils.DeleteDirectory(HostProjectFile.Directory.FullName);
}
}
示例3: FindGameContainingFile
/// <summary>
/// Find the game which contains a given input file.
/// </summary>
/// <param name="AllGameFolders">All game folders</param>
/// <param name="File">Full path of the file to search for</param>
protected UProjectInfo FindGameContainingFile(List<UProjectInfo> AllGames, FileReference File)
{
foreach (UProjectInfo Game in AllGames)
{
if (File.IsUnderDirectory(Game.Folder))
{
return Game;
}
}
return null;
}
示例4: TempStorageFile
/// <summary>
/// Constructor
/// </summary>
/// <param name="FileInfo">File to be added</param>
/// <param name="RootDir">Root directory to store paths relative to</param>
public TempStorageFile(FileInfo FileInfo, DirectoryReference RootDir)
{
// Check the file exists and is in the right location
FileReference File = new FileReference(FileInfo);
if(!File.IsUnderDirectory(RootDir))
{
throw new AutomationException("Attempt to add file to temp storage manifest that is outside the root directory ({0})", File.FullName);
}
if(!FileInfo.Exists)
{
throw new AutomationException("Attempt to add file to temp storage manifest that does not exist ({0})", File.FullName);
}
RelativePath = File.MakeRelativeTo(RootDir).Replace(Path.DirectorySeparatorChar, '/');
LastWriteTimeUtcTicks = FileInfo.LastWriteTimeUtc.Ticks;
Length = FileInfo.Length;
}
示例5: IsPublicAssembly
/// <summary>
/// Checks whether the given assembly is a publically distributed engine assembly.
/// </summary>
/// <param name="File">Assembly location</param>
/// <returns>True if the assembly is distributed publically</returns>
static bool IsPublicAssembly(FileReference File)
{
DirectoryReference EngineDirectory = UnrealBuildTool.UnrealBuildTool.EngineDirectory;
if(File.IsUnderDirectory(EngineDirectory))
{
string[] PathFragments = File.MakeRelativeTo(EngineDirectory).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
if(PathFragments.All(x => !x.Equals("NotForLicensees", StringComparison.InvariantCultureIgnoreCase) && !x.Equals("NoRedist", StringComparison.InvariantCultureIgnoreCase)))
{
return true;
}
}
return false;
}