public static StreamsContentsAreEqual ( Stream stream1, Stream stream2 ) : bool | ||
stream1 | Stream | |
stream2 | Stream | |
return | bool |
public static void MergeChanges(string backup, string file) { if (backup == null || !File.Exists(backup) || !File.Exists(file)) { return; } bool isEqual; using (var fs1 = new FileStream(backup, FileMode.Open)) using (var fs2 = new FileStream(file, FileMode.Open)) isEqual = CodeFileHelper.StreamsContentsAreEqual(fs1, fs2); if (isEqual) { File.Delete(backup); return; } var generated = Path.ChangeExtension(file, Path.GetExtension(file) + ".gen.bak"); File.Copy(file, generated, true); File.Copy(backup, file, true); if (Kdiff3Path.IsNullOrEmpty() || !File.Exists(Kdiff3Path)) { throw new InvalidOperationException(String.Format("KDiff3, verilen '{0}' konumunda bulunamadı!", Kdiff3Path ?? "")); } Process.Start(Kdiff3Path, "--auto " + file + " " + generated + " -o " + file); }
public static void MergeChanges(string backup, string file) { if (backup == null || !File.Exists(backup) || !File.Exists(file)) { return; } bool isEqual; using (var fs1 = new FileStream(backup, FileMode.Open)) using (var fs2 = new FileStream(file, FileMode.Open)) isEqual = CodeFileHelper.StreamsContentsAreEqual(fs1, fs2); if (isEqual) { File.Delete(backup); return; } var generated = Path.ChangeExtension(file, Path.GetExtension(file) + ".gen.bak"); CheckoutAndWrite(generated, File.ReadAllBytes(file), false); CheckoutAndWrite(file, File.ReadAllBytes(backup), true); if (Kdiff3Path.IsNullOrEmpty() || !File.Exists(Kdiff3Path)) { if (Kdiff3Path.IsNullOrEmpty()) { throw new Exception( "Couldn't locate KDiff3 utility which is required to merge changes. " + "Please install it, or if it is not installed to default location, " + "set its path in CodeGenerator.config file!"); } throw new Exception(String.Format( "Couldn't locate KDiff3 utility at '{0}' which is required to merge changes. " + "Please install it, or if it is not installed to default location, " + "set its path in CodeGenerator.config file!", Kdiff3Path)); } Process.Start(Kdiff3Path, "--auto \"" + file + "\" \"" + generated + "\" -o \"" + file + "\""); }