/// <summary> /// Executes the Task. /// </summary> /// <returns>true if the task successfully executed; otherwise, false.</returns> public override bool Execute() { if (!Directory.Exists(this.SourceDirectory)) { // can't run if the directory doesn't exist base.Log.LogError("The source directory specified does not exist."); return(false); } if (!Directory.Exists(this.DestinationDirectory)) { // can't run if the directory doesn't exist base.Log.LogError("The destination directory specified does not exist."); return(false); } base.Log.LogMessage(MessageImportance.Normal, "Comparing {0} to {1}", this.SourceDirectory, this.DestinationDirectory); var comparer = new ByteStreamComparer(); var result = comparer.Compare(this.SourceDirectory, this.DestinationDirectory); try { this.HandleNewFiles(result, this.SourceDirectory); this.HandleModifiedFiles(result, this.SourceDirectory); this.HandleNotInSourceFiles(result, this.DestinationDirectory); } catch (Exception e) { base.Log.LogError(string.Format("The build task failed. The message was '{0}'", e.StackTrace)); return(false); } return(true); }
private static void ListDifferences(string source, string destination) { var comparer = new ByteStreamComparer(); var results = comparer.Compare(source, destination); foreach (var result in results.ModifiedFiles) { Console.WriteLine(result); } }
private static void ComparePerformance(string source, string destination) { for (var i = 0; i <= 4; i++) { var watch = new Stopwatch(); watch.Start(); IDirectoryComparer comparer = new ByteStreamComparer(); var byteStreamResults = comparer.Compare(source, destination); watch.Stop(); Console.WriteLine(string.Format("Byte Stream Comparer found changes in {0}", watch.Elapsed)); watch.Reset(); watch.Start(); comparer = new Sha1Comparer(); var sha1Results = comparer.Compare(source, destination); watch.Stop(); Console.WriteLine(string.Format("Sha1 Comparer found changes in {0}", watch.Elapsed)); } }
/// <summary> /// Executes the Task. /// </summary> /// <returns>true if the task successfully executed; otherwise, false.</returns> public override bool Execute() { if (!Directory.Exists(this.SourceDirectory)) { // can't run if the directory doesn't exist base.Log.LogError("The source directory specified does not exist."); return false; } if (!Directory.Exists(this.DestinationDirectory)) { // can't run if the directory doesn't exist base.Log.LogError("The destination directory specified does not exist."); return false; } base.Log.LogMessage(MessageImportance.Normal, "Comparing {0} to {1}", this.SourceDirectory, this.DestinationDirectory); var comparer = new ByteStreamComparer(); var result = comparer.Compare(this.SourceDirectory, this.DestinationDirectory); try { this.HandleNewFiles(result, this.SourceDirectory); this.HandleModifiedFiles(result, this.SourceDirectory); this.HandleNotInSourceFiles(result, this.DestinationDirectory); } catch (Exception e) { base.Log.LogError(string.Format("The build task failed. The message was '{0}'", e.StackTrace)); return false; } return true; }