|
@@ -440,11 +440,6 @@ End;
|
|
|
|
|
|
|
|
|
Function SeekEof (Var t : Text) : Boolean;
|
|
|
-var
|
|
|
- oldfilepos : Int64;
|
|
|
- oldbufpos, oldbufend : SizeInt;
|
|
|
- reads: longint;
|
|
|
- isdevice: boolean;
|
|
|
Begin
|
|
|
If (InOutRes<>0) then
|
|
|
exit(true);
|
|
@@ -456,31 +451,12 @@ Begin
|
|
|
InOutRes:=103;
|
|
|
exit(true);
|
|
|
end;
|
|
|
- { try to save the current position in the file, seekeof() should not move }
|
|
|
- { the current file position (JM) }
|
|
|
- oldbufpos := TextRec(t).BufPos;
|
|
|
- oldbufend := TextRec(t).BufEnd;
|
|
|
- reads := 0;
|
|
|
- oldfilepos := -1;
|
|
|
- isdevice := Do_IsDevice(TextRec(t).handle);
|
|
|
repeat
|
|
|
If TextRec(t).BufPos>=TextRec(t).BufEnd Then
|
|
|
begin
|
|
|
- { signal that the we will have to do a seek }
|
|
|
- inc(reads);
|
|
|
- if not isdevice and
|
|
|
- (reads = 1) then
|
|
|
- begin
|
|
|
- oldfilepos := Do_FilePos(TextRec(t).handle) - TextRec(t).BufEnd;
|
|
|
- InOutRes:=0;
|
|
|
- end;
|
|
|
FileFunc(TextRec(t).InOutFunc)(TextRec(t));
|
|
|
If TextRec(t).BufPos>=TextRec(t).BufEnd Then
|
|
|
begin
|
|
|
- { if we only did a read in which we didn't read anything, the }
|
|
|
- { old buffer is still valid and we can simply restore the }
|
|
|
- { pointers (JM) }
|
|
|
- dec(reads);
|
|
|
SeekEof := true;
|
|
|
break;
|
|
|
end;
|
|
@@ -502,24 +478,6 @@ Begin
|
|
|
end;
|
|
|
inc(TextRec(t).BufPos);
|
|
|
until false;
|
|
|
- { restore file position if not working with a device }
|
|
|
- if not isdevice then
|
|
|
- { if we didn't modify the buffer, simply restore the BufPos and BufEnd }
|
|
|
- { (the latter because it's now probably set to zero because nothing was }
|
|
|
- { was read anymore) }
|
|
|
- if (reads = 0) then
|
|
|
- begin
|
|
|
- TextRec(t).BufPos:=oldbufpos;
|
|
|
- TextRec(t).BufEnd:=oldbufend;
|
|
|
- end
|
|
|
- { otherwise return to the old filepos and reset the buffer }
|
|
|
- else
|
|
|
- begin
|
|
|
- do_seek(TextRec(t).handle,oldfilepos);
|
|
|
- InOutRes:=0;
|
|
|
- FileFunc(TextRec(t).InOutFunc)(TextRec(t));
|
|
|
- TextRec(t).BufPos:=oldbufpos;
|
|
|
- end;
|
|
|
End;
|
|
|
|
|
|
|