Exemple #1
0
        public long FindPositionData(long StartPosition)
        {
            if (Scanner.MinDataLengthBytes == 0)
            {
                throw new Exception("Укажите данные поиска");
            }

            TailBytes.Clear();
            Scanner.BufferBytes.Clear();
            this.FileFilteredReadStream.Scanner.BufferBytes.Clear();

            long finded_position = -1;

            long original_position_of_stream = Position;

            long file_length = Length;

            long WorkingReadPosition = Position = StartPosition;

            while (WorkingReadPosition <= file_length || this.FileFilteredReadStream.Scanner.BufferBytes.Count > 0)
            {
                int this_byte = FileFilteredReadStream.ReadByte();
                AddToBuffer(this_byte);
                if (Scanner.ScanResult != null && Scanner.ScanResult.SuccessMatch)
                {
                    Position        = Position - Scanner.ScanResult.MatchUnit.GetDetectedSearchData().Length - this.FileFilteredReadStream.Scanner.BufferBytes.Count;
                    finded_position = Position;
                    break;
                }
                WorkingReadPosition++;
            }

            Position = original_position_of_stream;
            return(finded_position);
        }
Exemple #2
0
        private void AddToBuffer(int curr_byte)
        {
            if (curr_byte < 0)
            {
                return;
            }
            TailBytes.Add((byte)curr_byte);
            Scanner.AddToBuffer((byte)curr_byte);

            Scanner.CheckData();
        }