本文整理汇总了C#中FileReference.MakeRelativeTo方法的典型用法代码示例。如果您正苦于以下问题:C# FileReference.MakeRelativeTo方法的具体用法?C# FileReference.MakeRelativeTo怎么用?C# FileReference.MakeRelativeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReference
的用法示例。
在下文中一共展示了FileReference.MakeRelativeTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Write
/// <summary>
/// Writes a preprocessed build graph to a script file
/// </summary>
/// <param name="File">The file to load</param>
/// <param name="SchemaFile">Schema file for validation</param>
public void Write(FileReference File, FileReference SchemaFile)
{
XmlWriterSettings Settings = new XmlWriterSettings();
Settings.Indent = true;
Settings.IndentChars = "\t";
using (XmlWriter Writer = XmlWriter.Create(File.FullName, Settings))
{
Writer.WriteStartElement("BuildGraph", "http://www.epicgames.com/BuildGraph");
if (SchemaFile != null)
{
Writer.WriteAttributeString("schemaLocation", "http://www.w3.org/2001/XMLSchema-instance", "http://www.epicgames.com/BuildGraph " + SchemaFile.MakeRelativeTo(File.Directory));
}
foreach (Agent Agent in Agents)
{
Agent.Write(Writer, null);
}
foreach (ManualTrigger ControllingTrigger in Agents.SelectMany(x => x.Nodes).Where(x => x.ControllingTrigger != null).Select(x => x.ControllingTrigger).Distinct())
{
Writer.WriteStartElement("Trigger");
Writer.WriteAttributeString("Name", ControllingTrigger.QualifiedName);
foreach (Agent Agent in Agents)
{
Agent.Write(Writer, ControllingTrigger);
}
Writer.WriteEndElement();
}
foreach (KeyValuePair<string, Node[]> Aggregate in AggregateNameToNodes)
{
Writer.WriteStartElement("Aggregate");
Writer.WriteAttributeString("Name", Aggregate.Key);
Writer.WriteAttributeString("Requires", String.Join(";", Aggregate.Value.Select(x => x.Name)));
Writer.WriteEndElement();
}
foreach (Report Report in NameToReport.Values)
{
Writer.WriteStartElement("Report");
Writer.WriteAttributeString("Name", Report.Name);
Writer.WriteAttributeString("Requires", String.Join(";", Report.Nodes.Select(x => x.Name)));
Writer.WriteEndElement();
}
foreach (Badge Badge in Badges)
{
Writer.WriteStartElement("Badge");
Writer.WriteAttributeString("Name", Badge.Name);
if (Badge.Project != null)
{
Writer.WriteAttributeString("Project", Badge.Project);
}
Writer.WriteAttributeString("Requires", String.Join(";", Badge.Nodes.Select(x => x.Name)));
Writer.WriteEndElement();
}
Writer.WriteEndElement();
}
}
示例3: 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;
}
示例4: 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;
}