THandleStream.SetSize doesn't change position property
Original Reporter info from Mantis: marcelo_rocha
-
Reporter name: Marcelo Campos Rocha
Original Reporter info from Mantis: marcelo_rocha
- Reporter name: Marcelo Campos Rocha
Description:
The current implementation only call FileTruncate. Delphi's documentation(http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Classes_THandleStream_SetSize@Int64.html) describes that before truncate, seek is called to position the file at the new end.
Steps to reproduce:
program Project1;
{$mode delphi}
uses
SysUtils, Classes;
var
f: TFileStream;
content: AnsiString;
begin
f := TFileStream.Create('file.txt', fmCreate);
content := 'file content';
f.Write(PAnsiChar(content)^, Length(content));
f.Size := 4;
Writeln('File position should be 4 but it''s ', f.Position);
f.free;
end.