[Wiki] Erreur dans http://wiki.freepascal.org/File_Handling_In_Pascal
Bonjour,
si quelqu'un a un compte, ça serait bien qu'il poste ce qui suit dans la page "discussion" :
+++
Wrong test in last example of Generic files of any type (starting with "With larger files of many Gb, ...")
Hello,
The test
Code:
while TotalBytesRead <= FileStream.Size do // While the amount of data read is less than or equal to the size of the stream do
never terminates... Should be
Code:
while TotalBytesRead < FileStream.Size do // While the amount of data read is less than to the size of the stream do
because TotalBytesRead will never reach FileStream.Size : starting at 0, TotalBytesRead grows up to FileStream.Size -1 !
Tested with
Code:
1 2 3 4 5 6 7 8 9 10 11
| while TotalBytesRead < FileStream.Size do // While the amount of data read is less than to the size of the stream do
begin
BytesRead := FileStream.Read(Buffer,sizeof(Buffer)); // Read in 4096 of data
inc(TotalBytesRead, BytesRead); // Increase TotalBytesRead by the size of the buffer, i.e. 4096 bytes
// Do something with Buffer data
end;
finally
FileStream.Free
end;
ShowMessage(IntToStr(TotalBytesRead)); // Shows the same value as FileSize
end; |
+++
Merci et bon week-end,
:coucou: