/// <summary> /// Adds one file as a counterpart to the other /// </summary> /// <param name="BranchRoot">Root directory for the branch</param> /// <param name="FirstFileName">Path to the first file from the branch root directory</param> /// <param name="SecondFileName">Path to the second file from the branch root directory</param> static void AddCounterpart(DirectoryReference BranchRoot, string FirstFileName, string SecondFileName) { SourceFile FirstFile = Workspace.GetFile(FileReference.Combine(BranchRoot, FirstFileName)).ReadSourceFile(); SourceFile SecondFile = Workspace.GetFile(FileReference.Combine(BranchRoot, SecondFileName)).ReadSourceFile(); FirstFile.SetCounterpart(SecondFile); }
/// <summary> /// Sets the counterpart on a file, and checks that it meets the requirements for doing so /// </summary> /// <param name="File"></param> /// <param name="CounterpartFile"></param> public void SetCounterpart(SourceFile OtherFile) { if (Counterpart != OtherFile) { if (Counterpart != null) { throw new Exception("File already has a counterpart set"); } Counterpart = OtherFile; if (HasHeaderGuard) { throw new Exception("Files with counterparts may not have a header guard, since they will be included directly."); } OtherFile.SetCounterpart(this); } }