Wenn du die Datei komplett in den Speicher laden kannst (ungetestet):
Delphi-Quellcode:
function Search(_Stream: TStream): Boolean;
var
data:
array of Byte;
search:
array of Byte;
i: int64;
j: int64;
fnd: Boolean;
begin
// daten sind im stream
_Stream.Position := 0;
Result := False;
if _Stream.Size = 0
then
Exit;
// -->
SetLength(data, _Stream.Size);
if _Stream.
read(data[0], _Stream.Size) <> _Stream.size
then
raise Exception.Create('
Fehler beim Lesen der Daten');
SetLength(search, 6);
search[0] := $58;
search[1] := $50;
search[2] := $52;
search[3] := $30;
search[4] := $00;
search[5] := $28;
for i := Low(Data)
to High(Data) - Length(search) + 1
do begin
fnd := True;
for j := Low(search)
to High(Search)
do begin
if data[i] <> search[j]
then begin
fnd := False;
break;
// -->
end;
end;
if fnd
then begin
Result := True;
_Stream.Position := i;
Exit;
// ->
end;
end;
end;