Example #1
0
 public MinimumStreamTargetFile(byte[] targetFileBytes, int maximumLength, CollectionFileType FileTypeTargets)
 {
     FilteredFileTypeTargets   = FileTypeTargets;
     _maximumLength            = maximumLength;
     MinimumTargetFileSequence = new byte[_maximumLength];
     Array.Copy(targetFileBytes, MinimumTargetFileSequence, _maximumLength);
 }
Example #2
0
        public bool IsFileExtensionCorrect(string extension, byte[] rawContent)
        {
            if (extension == null)
            {
                return(false);
            }
            CollectionFileType FileTypeTargets = new CollectionFileType(KnownFileSignatures.List.FindAll(
                                                                            delegate(FileType ft)
            {
                return(Array.IndexOf(ft.Extension.Split(','), extension) >= 0);
            }
                                                                            ));

            if (FileTypeTargets.List.Count == 0)
            {
                return(false);
            }
            foreach (FileType FT in FileTypeTargets)
            {
                if (FT.Matches(rawContent))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        public CollectionFileType GetMatchingFileTypes()
        {
            CollectionFileType AllFT_Matches = new CollectionFileType();

            foreach (FileType FT in FilteredFileTypeTargets)
            {
                if (FT.Matches(MinimumTargetFileSequence))
                {
                    AllFT_Matches.AddFileType(FT);
                }
            }
            return(AllFT_Matches.Count == 0 ? new CollectionFileType(new[] { FileType.Unknown }) : AllFT_Matches);
        }
Example #4
0
        public CollectionFileType GetFileExtension(byte[] rawContent)
        {
            CollectionFileType FileTypeTargets = new CollectionFileType();

            int MaximumLengthForMatch = 0;

            foreach (FileType CurrFileType in KnownFileSignatures)
            {
                int CurrFileSignatureLength = CurrFileType.GetMaxSignatureLength();
                int MinResult = Math.Min(CurrFileSignatureLength, rawContent.Length);
                if (MinResult == CurrFileSignatureLength)
                {
                    FileTypeTargets.AddFileType(CurrFileType);
                    MaximumLengthForMatch = Math.Max(MaximumLengthForMatch, CurrFileSignatureLength);
                }
            }
            MSTF = new MinimumStreamTargetFile(rawContent, MaximumLengthForMatch, FileTypeTargets);
            return(MSTF.GetMatchingFileTypes());
        }
Example #5
0
 public FileTypeTeller(CollectionFileType KnownFileSignatures)
 {
     this.KnownFileSignatures = KnownFileSignatures;
 }