[fpc-devel] TFileStream problem with bigger file (> GB)?
fpc at mfriebe.de
Wed Mar 10 02:53:18 CET 2010
I have a strange issue with TFileStream, just wondering if anything is
The function below is supposed to read the first (up to) 5000 bytes of a
file. It works fine on "normal" sized files.
But I have a couple of files between 3 and 8 GB in size, and for those
files read just returns buf filled with zeros.
The output shows, that fs.read returns 5000, that is it claims that the
full amount has been read.
Smaller files on the same filesystem do work. there are no spaces in the
filename or directory.
This happens on windows, fpc from trunc (older and today).
> function TFileInfo.GetChecksum: Integer;
> PRE_READ_SIZE = 5000;
> c, i: Integer;
> fs: TFileStream;
> buf: Array [0..PRE_READ_SIZE] of Byte;
> if FChecksumDone then exit(FChecksum);
> c := 0;
> fs := TFileStream.Create(Dir + Name, fmOpenRead);
> debugln(['## ',
> fs.Read(buf, PRE_READ_SIZE)
> for i := 0 to PRE_READ_SIZE - 1 do begin
> c := c + buf[i];
> if i > 0 then
> c := (c + (buf[i] * buf[i-1])) AND $7fffff;
> debugln(['--- ',Name,' ',c]);
> FChecksum := c;
> FChecksumDone := True;
> Result := FChecksum;
More information about the fpc-devel