/// <summary> /// Public compare function: /// Compare the source path with the target path and return only the files in source folder /// that are different from files in the target folder. /// </summary> /// <param name="sourcePath">Path of source folder.</param> /// <param name="targetPath">Path of target folder.</param> /// <returns>Album containing the files/folders in source folder that are different.</returns> public DiffResult compare(string sourcePath, string targetPath) { #region Pre Conditions Debug.Assert(sourcePath != null, "Source Path cannot be null"); Debug.Assert(targetPath != null, "Target Path cannot be null"); #endregion // Create the Result Album DiffResult diffResult = new DiffResult(); Album result = new Album(DIFF_ALBUM_NAME, string.Empty); // Initiate the Stack for Recursion Stack<DiffStackContent> recursive = new Stack<DiffStackContent>(); DiffStackContent stackContent = new DiffStackContent(sourcePath, targetPath); recursive.Push(stackContent); do /* Do-While Loop for Performance */ { // Get the sourcePath and targetPath: POP from Stack stackContent = recursive.Pop(); sourcePath = stackContent.source; targetPath = stackContent.target; // Compare Files diffCompareFiles(sourcePath, targetPath, diffResult, result); // Get Sub Folders for Recursion getSubFoldersForRecursion(sourcePath, targetPath, diffResult, result, recursive); } while (recursive.Count != 0); // Return Result diffResult.setResult(result); #region Post Conditions Debug.Assert(diffResult != null, "Diff Result Cannot be null"); #endregion return diffResult; }