// 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; using Tools.DotNETCommon; namespace Tools.DotNETCommon { /// /// Names of restricted folders. Note: The name of each entry is used to search for/create folders /// public enum RestrictedFolder { /// /// Legacy. Should not be used any more. /// EpicInternal, /// /// Can be used by UE4 but not required /// CarefullyRedist, /// /// Epic Employees and Contractors /// NotForLicensees, /// /// Epic Employees only /// NoRedist, /// /// Playstation 4 source files /// PS4, /// /// XboxOne source files /// XboxOne, /// /// Switch source files /// Switch, /// /// Quail source files /// Quail, } /// /// Utility functions for getting restricted folder /// public static class RestrictedFolders { /// /// Public array of restricted folder names /// public static readonly string[] Names; /// /// Public array of restricted folder names /// public static readonly RestrictedFolder[] Values; /// /// Keeps a cache of folder substrings and flags /// static readonly Tuple[] NamesAndValues; /// /// Static constructor /// static RestrictedFolders() { Names = Enum.GetNames(typeof(RestrictedFolder)); Values = (RestrictedFolder[])Enum.GetValues(typeof(RestrictedFolder)); NamesAndValues = new Tuple[Names.Length]; for(int Idx = 0; Idx < Names.Length; Idx++) { NamesAndValues[Idx] = Tuple.Create(Names[Idx], Values[Idx]); } } /// /// Finds all the restricted folder names relative to a base directory /// /// The base directory to check against /// The file or directory to check /// Array of restricted folder names public static List FindRestrictedFolders(DirectoryReference BaseDir, DirectoryReference OtherDir) { List Folders = new List(); if(OtherDir.IsUnderDirectory(BaseDir)) { foreach(Tuple Pair in NamesAndValues) { if(OtherDir.ContainsName(Pair.Item1, BaseDir.FullName.Length)) { Folders.Add(Pair.Item2); } } } return Folders; } } }