Пример #1
0
        private static bool IsMatchingType(IList <byte> input, FileTypeInfo type)
        {
            // find an initial match based on the header and offset
            var isMatch = FindMatch(input, type.Header, type.Offset);

            // some file types (Microsoft) have the same header
            // but different signature in another location, if its one of these determine what the true file type is
            if (isMatch && type.AdditionalIdentifier.Length > 0)
            {
                // find all indices of matching the 1st byte of the additional sequence
                var matchingIndices = input.Select((b, i) => b == type.AdditionalIdentifier[0] ? i : -1).Where(i => i != -1).ToList();

                // investigate all of them for a match
                isMatch = matchingIndices.Any(i => FindMatch(input, type.AdditionalIdentifier, i));
            }

            return(isMatch);
        }
        private static bool IsMatchingType(IList<byte> input, FileTypeInfo type)
        {
            // find an initial match based on the header and offset
            var isMatch = FindMatch(input, type.Header, type.Offset);

            // some file types (Microsoft) have the same header
            // but different signature in another location, if its one of these determine what the true file type is
            if (isMatch && type.AdditionalIdentifier.Length > 0)
            {
                // find all indices of matching the 1st byte of the additional sequence
                var matchingIndices = input.Select((b, i) => b == type.AdditionalIdentifier[0] ? i : -1).Where(i => i != -1).ToList();

                // investigate all of them for a match
                isMatch = matchingIndices.Any(i => FindMatch(input, type.AdditionalIdentifier, i));
            }

            return isMatch;
        }