Set the current file position on a file handle.
Source position: filutilh.inc line 221
function FileSeek(
Handle: THandle ;
FOffset: LongInt ;
Origin: LongInt
):LongInt ;
function FileSeek(
Handle: THandle ;
FOffset: Int64 ;
Origin: LongInt
):Int64 ;
FileSeek sets the file pointer on position Offset, starting from Origin. Origin can be one of the following values:
If successful, the function returns the new file position, relative to the beginning of the file.
On error, -1 is returned.
Close a file handle.
Write data from a buffer to a given file handle.
Create a new file and return a handle to it.
Open an existing file and return a file handle
Read data from a file handle in a buffer.
Truncate an open file to a given size.
Program Example37; { This program demonstrates the FileCreate/FileSeek/FileReed/FileTruncate functions } Uses sysutils; Var I,J,F : Longint; Begin F:=FileCreate ('test.dat'); If F=-1 then Halt(1); For I:=0 to 100 do FileWrite(F,I,SizeOf(i)); FileClose(f); F:=FileOpen ('test.dat',fmOpenRead); For I:=0 to 100 do begin FileRead (F,J,SizeOF(J)); If J<>I then Writeln ('Mismatch at file position ',I) end; FileSeek(F,0,fsFromBeginning); Randomize; Repeat FileSeek(F,Random(100)*4,fsFromBeginning); FileRead (F,J,SizeOf(J)); Writeln ('Random read : ',j); Until J>80; FileClose(F); F:=FileOpen('test.dat',fmOpenWrite); I:=50*SizeOf(Longint); If FileTruncate(F,I) then Writeln('SuccessFully truncated file to ',I,' bytes.'); FileClose(F); End.