コード例 #1
0
ファイル: FileMatchFinder.cs プロジェクト: lerpinglemur/Lemur
		} //

		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
ファイル: FileMatchFinder.cs プロジェクト: lerpinglemur/Lemur
		/// <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
ファイル: FileMatchFinder.cs プロジェクト: lerpinglemur/Lemur
		} //

		/// <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;

		}