Files
UnrealEngineUWP/Engine/Source/Programs/DotNETCommon/DotNETUtilities/DirectoryUtils.cs
ben marsh 25fe339213 Add missing copyright notices.
#rb none
#rnx
#jira UE-74628

#ROBOMERGE-OWNER: lina.halper
#ROBOMERGE-AUTHOR: ben.marsh
#ROBOMERGE-SOURCE: CL 6455289 in //UE4/Release-4.22/... via CL 6455290
#ROBOMERGE-BOT: ANIM (Main -> Dev-Anim)

[CL 6474676 by ben marsh in Dev-Anim branch]
2019-05-15 08:12:05 -04:00

52 lines
1.3 KiB
C#

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tools.DotNETCommon
{
/// <summary>
/// Utility functions for manipulating directories
/// </summary>
public class DirectoryUtils
{
/// <summary>
/// Finds the on-disk case of a a directory
/// </summary>
/// <param name="Info">DirectoryInfo instance describing the directory</param>
/// <returns>New DirectoryInfo instance that represents the directory with the correct case</returns>
public static DirectoryInfo FindCorrectCase(DirectoryInfo Info)
{
DirectoryInfo ParentInfo = Info.Parent;
if (ParentInfo == null)
{
string FullName = Info.FullName;
if (FullName.Length >= 2 && (FullName[0] >= 'a' && FullName[0] <= 'z') && FullName[1] == ':')
{
return new DirectoryInfo(Char.ToUpper(FullName[0]) + FullName.Substring(1));
}
else
{
return Info;
}
}
else
{
ParentInfo = FindCorrectCase(ParentInfo);
foreach (DirectoryInfo ChildInfo in ParentInfo.EnumerateDirectories())
{
if (String.Equals(ChildInfo.Name, Info.Name, DirectoryReference.Comparison))
{
return ChildInfo;
}
}
return new DirectoryInfo(Path.Combine(ParentInfo.FullName, Info.Name));
}
}
}
}