جستجوی سریع فایل رشته ای با کد دلفی

function StringInFile(strFind, strFileName: string): boolean; const BUFSIZE = 8192; var fstm: TFileStream; numread: Longint; buffer: array [0..BUFSIZE-1] of char; szFind: array [0..255] of char; found: boolean; begin StrPCopy(szFind, strFind); found := False; fstm := TFileStream.Create(strFileName, fmOpenRead); repeat numread := fstrm.Read(Buffer, BUFSIZE); if BMFind(szFind, Buffer, numread) >= 0 then found := True else if numread = BUFSIZE then // more to scan fstm.Position := fstmPosition - (Length(strFind)-1); until found or (numread < BUFSIZE); fstm.Free; Result := found; end;
/ 0 نظر / 25 بازدید