On Wed, 29 Jul 2009, Micha Nelissen wrote:

Andrew Haines wrote:
procedure tfor...@unzipcustomoutput(Sender: TObject; var AStream:
            TStream; AItem: TFullZipFileEntry; AClosing: Boolean);
begin
  if AClosing = False then
  begin
    AStream := TMemoryStream.Create;
  end

Do you mind if I say I think this is a very weird event handler?

What is the behaviour? How many times is it called? What does AClosing mean? How do I know I don't have a memory leak?

Why an event handler and not a property? A CustomStream property where non-nil means use this stream, if nil then default old behaviour e.g.

Well, maybe a bit awkward, but the handler makes sense.

Your Customstream is not possible, because multiple files must be extracted
to different streams.

The handler is called 2 times:
- Once to create the stream (aclosing=false)
- Once when the data has been written to the steam. (AClosing=true)

Maybe it had been better to create 2 events:
- OnCreateStream
- OnDestroyStream (optional, if not set the component frees the stream)

What do you think ?

Michael.
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to