function TextPos(var F: TextFile): Int64;
var
TR: TTextRec absolute F;
begin
Result := FileSeek(TR.Handle, 0, FILE_CURRENT);
if TR.Mode = fmOutput then
Inc(Result, TR.BufPos)
else
if TR.BufEnd <> 0 then
Dec(Result, TR.BufEnd - TR.BufPos);
end;
function TextSeek(var F: TextFile; Pos: Int64): boolean;
var
// Pos64: Int64Rec absolute Pos;
// resHi: cardinal;
TR: TTextRec absolute F;
begin
Result := False;
if TR.Mode <> fmInput then
Exit;
FileSeek(TR.Handle, Pos, FILE_BEGIN);
// resHi := Pos64.Hi;
// if (SetFilePointer(TR.Handle, Pos64.Lo,@resHi,FILE_BEGIN)<>Pos64.Lo) or (resHi<>Pos64.Hi) then
// Exit;
//
// TR.BufEnd := 0; // flush internal reading buffer
// TR.BufPos := 0;
// Result := True; // success
Result := FileSeek(TR.Handle, Pos, FILE_BEGIN) = Pos;
end;