예제 #1
0
        /// <summary>
        /// Fill any missing size and hash information from another Rom
        /// </summary>
        /// <param name="other">Rom to fill information from</param>
        public void FillMissingInformation(Rom other)
        {
            if (Size == null && other.Size != null)
            {
                Size = other.Size;
            }

            if (_crc.IsNullOrEmpty() && !other._crc.IsNullOrEmpty())
            {
                _crc = other._crc;
            }

            if (_md5.IsNullOrEmpty() && !other._md5.IsNullOrEmpty())
            {
                _md5 = other._md5;
            }

            if (_sha1.IsNullOrEmpty() && !other._sha1.IsNullOrEmpty())
            {
                _sha1 = other._sha1;
            }

            if (_sha256.IsNullOrEmpty() && !other._sha256.IsNullOrEmpty())
            {
                _sha256 = other._sha256;
            }

            if (_sha384.IsNullOrEmpty() && !other._sha384.IsNullOrEmpty())
            {
                _sha384 = other._sha384;
            }

            if (_sha512.IsNullOrEmpty() && !other._sha512.IsNullOrEmpty())
            {
                _sha512 = other._sha512;
            }

            if (_spamsum.IsNullOrEmpty() && !other._spamsum.IsNullOrEmpty())
            {
                _spamsum = other._spamsum;
            }
        }
예제 #2
0
        /// <summary>
        /// Convert a media to the closest Rom approximation
        /// </summary>
        /// <returns></returns>
        public Rom ConvertToRom()
        {
            var rom = new Rom()
            {
                ItemType = ItemType.Rom,
                DupeType = this.DupeType,

                Machine = this.Machine.Clone() as Machine,
                Source  = this.Source.Clone() as Source,
                Remove  = this.Remove,

                Name    = this.Name + ".aif",
                MD5     = this.MD5,
                SHA1    = this.SHA1,
                SHA256  = this.SHA256,
                SpamSum = this.SpamSum,
            };

            return(rom);
        }
예제 #3
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));
        }