FilePos Function
FilePos
returns the
current position (as a record number) in the file
F
. The beginning of the file is position zero. If
F
is a TextFile
, the record
size is arbitrarily chosen as the buffer size, which defaults to 128.
When Eof(F)
is True, FilePos
returns the number of records in the file. FilePos
is not a real function.
If the file F
is not open,
FilePos
reports I/O error 103.
Although you can get the file position in a text file, you cannot use
it to seek to that position. The Seek
procedure
works only with binary files. To get a file position of a text file,
use the Windows API:
// Return a byte position in a text file if its buffer is empty. function TextFilePos(var F: TextFile): LongInt; begin Result := SetFilePointer(TTextRec(F).Handle, 0, nil, File_Current); end;
FilePos
does not support files larger than 2 GB.
See the FileSeek
function in the
SysUtils
unit, or call the Windows API for large
files.