예제 #1
0
		} //

		private void FindAllMatches() {

			ICollection<FileMatchGroup> matches = this.matches;

			List<FileDuplicateInfo> fileSizes = this.GetFileSizes( this._baseSearchDir, this.RecursiveSearch );
			int totalFiles = fileSizes.Count;


			for ( int fileIndex = 0; fileIndex < totalFiles; fileIndex++ ) {

				if( this.CancelRequested() ) {
					return;
				}

				FileDuplicateInfo curFile = fileSizes[fileIndex];
				if ( string.IsNullOrEmpty(curFile.path) ) {
					// file was already assigned to a group. messy marker...
					continue;
				}
				
				FileMatchGroup match = this.FindMatches( fileSizes, curFile, fileIndex );
				if ( match != null ) {
					this.AddMatchGroup( match );
				}

			} // for-loop

		} //
예제 #2
0
		/// <summary>
		/// Adds a match group to the Matches collection.
		/// If a collection lock exists, the matches collection is
		/// locked before access.
		/// </summary>
		/// <param name="group"></param>
		private void AddMatchGroup( FileMatchGroup group ) {

			if( this.collectionLock != null ) {

				this.Dispatch( ()=> {

					lock( this.collectionLock ) {

						this.matches.Add( group );

					}
				}

				);

			} else {
				this.matches.Add( group );
			}

		}
예제 #3
0
		} //

		/// <summary>
		/// Private method runs the logic of finding mathces.
		/// </summary>
		/// <param name="allFiles"></param>
		/// <param name="curFile"></param>
		/// <param name="fileIndex"></param>
		/// <returns></returns>
		private FileMatchGroup FindMatches( List<FileDuplicateInfo> allFiles, FileDuplicateInfo curFile, int fileIndex ) {

			FileMatchGroup matchGroup = null;
			int totalFiles = allFiles.Count;
			long fileSize = curFile.size;

			for ( int nextIndex = fileIndex + 1; nextIndex < totalFiles; nextIndex++ ) {

				FileDuplicateInfo nextFile = allFiles[nextIndex];
				this.AdvanceFileProgress( nextFile.size );

				if ( string.IsNullOrEmpty( nextFile.path ) ) {
					// file was already used in a match.
					continue;
				} else if ( nextFile.size > fileSize ) {
					// different file size. no more matches to find.
					break;
				}

				/// POSSIBLE FILE MATCH.
				if ( this.CompareFiles( curFile.path, nextFile.path, fileSize ) ) {

					if ( matchGroup == null ) {
						matchGroup = new FileMatchGroup( fileSize, curFile.path );
					}

					matchGroup.Add( nextFile.path );
					/// clear the entry so it isn't used again.
					allFiles[nextIndex] = new FileDuplicateInfo();

				}
				if ( this.CancelRequested() ) {
					break;
				}

			} // for-loop

			return matchGroup;

		}