How can I read and write a binary file larger than 7 GBytes?
The assign(f,'xx' and reset(f) work but when I go to start the file traversal, the eof(f) function does not work properly, I understand that it is because the TFileRec structure has the BufPos and BufEnd fields defined as cardinal and can only represent up to 4 GBytes.
What group of functions can I use to perform the described operation?
procedure TForm1.BtnSplitClick1(Sender: TObject);
Var
F,G : File Of RecCustom;
begin
System.Assign(F,'NameInputF');
System.Reset(F);
System.Assign(F,'NameOutputF');
System.Reset(F);
while Not System.Eof(F) Do Begin
BlockRead(F,Arr,1);
// Modifica record Arr
BlockWrite(G,Arr,1);
End;
System.Close(F);
end;
Thank you
The
assign()
, functionsreset()
and the like date back many years and, perhaps for compatibility reasons, have not been updated to support the features of modern file systems, eg such large files (which were simply unthinkable before).Delphi provides a number of classes that you can pull from to build a modern, object-oriented solution for processing files the way you want. The most basic would be using
TFileStream
, for example adapting your code, it could be something along the lines of: