private void ParseSourceFilesIntoGroups() { foreach (SourceFile CurSourceFile in SourceFiles) { EddieSourceFile SourceFile = CurSourceFile as EddieSourceFile; string FileName = SourceFile.Reference.GetFileName(); string FileExtension = Path.GetExtension(FileName); string FilePath = SourceFile.Reference.MakeRelativeTo(ProjectFilePath.Directory); string FilePathMac = Utils.CleanDirectorySeparators(FilePath, '/'); string ProjectRelativeSourceFile = CurSourceFile.Reference.MakeRelativeTo(ProjectFilePath.Directory); string RelativeSourceDirectory = Path.GetDirectoryName(ProjectRelativeSourceFile); // Use the specified relative base folder if (CurSourceFile.BaseFolder != null) // NOTE: We are looking for null strings, not empty strings! { RelativeSourceDirectory = Path.GetDirectoryName(CurSourceFile.Reference.MakeRelativeTo(CurSourceFile.BaseFolder)); } EddieFolder Group = FindFolderByRelativePath(ref Folders, RelativeSourceDirectory); if (Group != null) { if (FileName.EndsWith(".build.cs") || FileName.EndsWith(".Build.cs") || FileName.EndsWith(".csproj")) { Group.bIsModuleFolder = true; Group.WorksetPath = ProjectFilePath.FullName + "." + Group.Name + ".wkst"; } Group.FullPath = Path.GetDirectoryName(SourceFile.Reference.FullName); Group.Files.Add(SourceFile); } } }
public EddieFolder FindFolderByRelativePath(ref Dictionary <string, EddieFolder> Groups, string RelativePath) { string[] Parts = RelativePath.Split(Path.DirectorySeparatorChar); string CurrentPath = ""; Dictionary <string, EddieFolder> CurrentParent = Groups; foreach (string Part in Parts) { EddieFolder CurrentGroup; if (CurrentPath != "") { CurrentPath += Path.DirectorySeparatorChar; } CurrentPath += Part; if (!CurrentParent.ContainsKey(CurrentPath)) { CurrentGroup = new EddieFolder(Path.GetFileName(CurrentPath), CurrentPath); CurrentParent.Add(CurrentPath, CurrentGroup); } else { CurrentGroup = CurrentParent[CurrentPath]; } if (CurrentPath == RelativePath) { return(CurrentGroup); } CurrentParent = CurrentGroup.Folders; } return(null); }