static async Task <string> CompareFiles(string ofi, string nfi, PathMatchLevel matchLevel) { FileComparer cmp = GetComparerForFile(ofi); string diff = await cmp.Compare(ofi, nfi); if (!String.IsNullOrWhiteSpace(diff) || matchLevel != PathMatchLevel.FullMatch) { StringBuilder output = new StringBuilder(); output.AppendLine("Diff " + ofi + " vs " + nfi + ":"); switch (matchLevel) { case PathMatchLevel.CaseInsensitiveMatch: output.AppendLine("(NOTE: File paths differ in case)"); break; case PathMatchLevel.SubstitutionMatch: output.AppendLine("(NOTE: New file has no exact counterpart in old tree, using a substitution)"); break; } output.AppendLine(diff); return(output.ToString()); } return(String.Empty); }
protected static FileComparer GetComparerForFile(string fi) { FileComparer cmp = nullComparer; string ext = Path.GetExtension(fi); if (comparers.ContainsKey(ext)) { cmp = comparers[ext]; } return(cmp); }
static async Task <string> DumpFile(string fi) { FileComparer cmp = GetComparerForFile(fi); string dump = await cmp.Dump(fi); if (!String.IsNullOrWhiteSpace(dump)) { StringBuilder output = new StringBuilder(); output.AppendLine("Dump of " + fi + ":"); output.AppendLine(dump); return(output.ToString()); } return(String.Empty); }