using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace UnityEditor.AddressableAssets.Settings { internal interface ICcdFolder where T : class { void GetChildren(DirectoryInfo startDirectory); } internal class CcdBuildDataFolder : ICcdFolder { public string Name; public string Location; public List Environments = new List(); public void GetChildren(DirectoryInfo startDirectory) { var envDirs = startDirectory.GetDirectories().Where(d => !d.Attributes.HasFlag(FileAttributes.Hidden)); foreach (var dir in envDirs) { var envFolder = new CcdEnvironmentFolder(); envFolder.Name = dir.Name; envFolder.Location = dir.FullName; envFolder.GetChildren(dir); Environments.Add(envFolder); } } } internal class CcdEnvironmentFolder : ICcdFolder { public string Name; public string Location; public List Buckets = new List(); public void GetChildren(DirectoryInfo startDirectory) { var bucketDirs = startDirectory.GetDirectories().Where(d => !d.Attributes.HasFlag(FileAttributes.Hidden)); foreach (var dir in bucketDirs) { var bucketFolder = new CcdBucketFolder(); bucketFolder.Name = dir.Name; bucketFolder.Location = dir.FullName; bucketFolder.GetChildren(dir); Buckets.Add(bucketFolder); } } } internal class CcdBucketFolder : ICcdFolder { public string Name; public string Location; public List Badges = new List(); public void GetChildren(DirectoryInfo startDirectory) { var badgeDirs = startDirectory.GetDirectories().Where(d => !d.Attributes.HasFlag(FileAttributes.Hidden)); foreach (var dir in badgeDirs) { var badgeFolder = new CcdBadgeFolder(); badgeFolder.Name = dir.Name; badgeFolder.Location = dir.FullName; badgeFolder.GetChildren(dir); Badges.Add(badgeFolder); } } } internal class CcdBadgeFolder : ICcdFolder { public string Name; public string Location; public List Files = new List(); public void GetChildren(DirectoryInfo startDirectory) { Files = startDirectory.GetFiles().Where(f => !f.Attributes.HasFlag(FileAttributes.Hidden)).ToList(); } } }