Esempio n. 1
0
        public override bool Equals(DatItem other)
        {
            bool dupefound = false;

            // If we don't have a rom, return false
            if (ItemType != other.ItemType)
            {
                return(dupefound);
            }

            // Otherwise, treat it as a Rom
            Rom newOther = other as Rom;

            // If all hashes are empty but they're both nodump and the names match, then they're dupes
            if ((ItemStatus == ItemStatus.Nodump && newOther.ItemStatus == ItemStatus.Nodump) &&
                Name == newOther.Name &&
                !HasHashes() && !newOther.HasHashes())
            {
                dupefound = true;
            }

            // If we have a file that has no known size, rely on the hashes only
            else if (Size == null && HashMatch(newOther))
            {
                dupefound = true;
            }

            // Otherwise if we get a partial match
            else if (Size == newOther.Size && HashMatch(newOther))
            {
                dupefound = true;
            }

            return(dupefound);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns if any hashes are common with another Rom
        /// </summary>
        /// <param name="other">Rom to compare against</param>
        /// <returns>True if any hashes are in common, false otherwise</returns>
        private bool HashMatch(Rom other)
        {
            // If either have no hashes, we return false, otherwise this would be a false positive
            if (!HasHashes() || !other.HasHashes())
            {
                return(false);
            }

            // If neither have hashes in common, we return false, otherwise this would be a false positive
            if (!HasCommonHash(other))
            {
                return(false);
            }

            // Return if all hashes match according to merge rules
            return(ConditionalHashEquals(_crc, other._crc) &&
                   ConditionalHashEquals(_md5, other._md5) &&
                   ConditionalHashEquals(_sha1, other._sha1) &&
                   ConditionalHashEquals(_sha256, other._sha256) &&
                   ConditionalHashEquals(_sha384, other._sha384) &&
                   ConditionalHashEquals(_sha512, other._sha512) &&
                   ConditionalHashEquals(_spamsum, other._spamsum));
        }