示例#1
0
        private ComparableFileHash(FileData file, ComparableFileHashConfig config)
        {
            var fileFullName = file.FullName;

            if (!FileSystem.PathExists(fileFullName))
            {
                throw new FileNotFoundException(string.Format(Resources.Error_File_x_not_found, fileFullName));
            }

            HashChunkSize = config.HashChunkSize.Value;
            Debug.Assert(HashChunkSize > 0, Resources.Error_ComparableFileHash_Invalid_fragment_size);
            CompleteMatch    = config.CompleteMatch.Value;
            CompleteMismatch = config.CompleteMismatch.Value;
            Debug.Assert(CompleteMatch > CompleteMismatch, Resources.Error_ComparableFileHash_CompleteMatch_and_CompleteMismatch_is_defined_incorrectly);

            FileData       = file;
            Cache          = new List <byte[]>();
            FileReader     = new FileReader(fileFullName);
            TotalFragments = CalculateTotalFragments(file.Size, HashChunkSize);
        }
示例#2
0
 // ReSharper disable once LocalizableElement
 public FileHashComparer() : base(Guid.Parse("56E94DDC-1021-49D5-8DB1-FF1C92710978"), Resources.FileHashComparer_Name, Resources.FileHashComparer_Description)
 {
     Config = new ComparableFileHashConfig();
     ComparableFileFactory = new ComparableFileHash.Factory(Config);
     CandidatePredicate    = new ComparableFileHash.CandidatePredicate();
 }