public static void BuildChildNodes2 (IBuilder builder, Folder folder) { string path = GetFolderPath (folder); ProjectFileCollection files; List<string> folders; GetFolderContent (path, out files, out folders); foreach (ProjectFile file in files) builder.AddChild (file); foreach (string subfolder in folders) builder.AddChild (new Folder (subfolder, folder)); }
private void Create(UnityProjectState state) { assetDatabase = state.AssetDatabase; BaseDirectory = state.BaseDirectory; RootFolder = new Folder(""); folders = new Dictionary<string, Folder> {{RootFolder.RelativePath, RootFolder}}; // Build folder structure from files foreach (var file in assetDatabase.Files) AddFile(file); // Build folder structure from empty folders foreach (var emptyDirectory in assetDatabase.EmptyDirectories) AddEmptyDirectory(emptyDirectory); }
static public string GetFolderPath (Folder folder) { return folder.Path.FullPath; }
private void AddFile(string file) { var parentPath = GetParentDirectoryPath(file); Folder childFolder = null; while (!folders.ContainsKey(parentPath)) { var newFolder = new Folder(parentPath); if (childFolder != null) newFolder.Add(childFolder); folders.Add(parentPath, newFolder); childFolder = newFolder; parentPath = GetParentDirectoryPath(parentPath); } if (childFolder != null) folders[parentPath].Add(childFolder); var fileFolder = folders[GetParentDirectoryPath(file)]; fileFolder.Add(new File(file)); }
private void AddEmptyDirectory(string directory) { Folder childFolder = null; // Note: If there is a hierarchy of folders that only contain // folders, then the folders will not be added as part of the // files, therefore we need to add the entire hierarchy. while (!folders.ContainsKey(directory)) { var newFolder = new Folder(directory); if (childFolder != null) newFolder.Add(childFolder); folders.Add(directory, newFolder); childFolder = newFolder; directory = GetParentDirectoryPath(directory); } if (childFolder != null) folders[directory].Add(childFolder); }