Hi all,
I have a TMemoryStream decendent defined as follows :
TRomChecksum = Class(TMemoryStream)
PUBLIC
Count : BYTE; { Count of 512 byte blocks }
CkSum : BYTE; { Calculated checksum }
CkByte : BYTE; { Byte to be added to make checksum zero }
Constructor Create;
PROCEDURE CalculateChecksums;
END;
Within my program's implementation I'm using SetSize to set the size of the stream before outputting it :
PROCEDURE ChecksumFile(FileToCheck : STRING;
PadTo : INTEGER);
VAR RomFile : TRomChecksum;
BEGIN;
RomFile:=TRomChecksum.Create;
TRY
WITH RomFile DO
BEGIN;
LoadFromFile(FileName);
CalculateChecksums;
{ Update file *ONLY* if checksum not valid ! }
IF (CkSum <> 0) THEN
BEGIN;
Position:=(Count*512)-1; { Last byte }
Write(CkByte,1);
END;
WriteLn(Format('PadTo: %d, Count*512: %d, Romfile.Size:%d',[PadTo,(Count*512),RomFile.Size]));
IF (PadTo>=(Count*512)) THEN
RomFile.SetSize(PadTo);
SaveToFile(FileName);
WriteLn(Format('File : %s',[FileToCheck]));
WriteLn(Format('Blocks : %d',[Count]));
WriteLn(Format('Sum : $%2.2Xh',[CkSum]));
WriteLn(Format('CkByte : $%2.2Xh',[CkByte]));
WriteLn(Format('Final length : %d',[RomFile.Size]));
END;
FINALLY
RomFile.Free;
END;
END;
On entry Count is 4 (read from the rom being processed), and PadTo is fed in as 8192. Single stepping to make sure, it does execute the SetSize, but the size of the stream stubbonly stays at 2048 (Count * 512), as set by the checksum write above. Any idea what is going wrong here.
What I do find curious is that CTRL clicking on SetSize in my code takes me to the definition for TStream.SetSize which according to the docs does nothing. But I was under the impression that MemoryStream was a decendent of TStream that overrode that, and therefore TRomChecksum should too.
Tried in Laz 2.0.6 and then upgraded to 2.0.10 and problem still there.....
Cheers.
Phill.