/// <summary> /// Add a root file if it does not already exist. If the root /// file already exists then it is NOT overwritten. /// </summary> /// <param name="root">An object that represents the root /// file on the file system.</param> /// <returns>The root object.</returns> public Root AddRoot (Root root) { if (!root.CvsFile.Exists) { this.Touch(root); } this.WriteToFile(root); return root; }
/// <summary> /// Create a cvs file object given the full path and line of the file. /// </summary> /// <param name="file"></param> /// <param name="line"></param> /// <returns></returns> public ICvsFile CreateCvsObject (FileInfo file, string line) { ICvsFile entry; if (!System.Enum.IsDefined(typeof(FileType), file.Name)) { throw new UnsupportedFileTypeException(string.Format("Unknown cvs file type: {0}", file.Name)); } switch ((FileType)Enum.Parse(typeof(FileType), file.Name, true)) { case (FileType.Entries): { entry = new Entry(file, line); break; } case (FileType.Repository):{ entry = new Repository (file, line); break; } case (FileType.Root):{ entry = new Root (file, line); break; } case (FileType.Tag):{ entry = new Tag (file, line); break; } default:{ StringBuilder msg = new StringBuilder(); msg.Append("Unknown file type specified."); msg.Append("fileType=[").Append(file.Name).Append("]"); throw new UnsupportedFileTypeException (msg.ToString()); } } return entry; }