[delphizip] Re: TZipMaster 1.72 TFileExtraEvent need some help

  • From: "Roger Aelbrecht" <Roger.Aelbrecht@xxxxxxxxxx>
  • To: <delphizip@xxxxxxxxxxxxx>
  • Date: Thu, 9 Jan 2003 18:22:07 +0100

Russell Peters wrote:
> It took me ages to work that one out (I am or was a C programmer)
> try
> union CallBackData{
>     char FilenameOrMessage[512];
>     struct{
>         char FileName[504];
>         byte *Data;
>     }X;
> };
> I think that is about right anyway (that's what I visualised it as
> then nearly tore my hair out trying to implement it in Delphi)
> 
>>  Extra := CallBackData(ZRec^.FileNameOrMsg).Data;
> Extra := CallBackData(ZRec->FileNameOrMsg).X.Data;    {cast to
> CallBackData then get it's Data pointer}
> 
> Trying to work in Delphi has made it difficult to think in either (it
> normally ends up being a combination)
> Russell Peters
> http://www.users.bigpond.com/russellpeters/delphizip.html
> 
Don't know if previous mail got through OE seems to behave strange
The above solution does not work, getting compiler error
saying cannot: "convert char* to CallBackData"

After some more thinking I found a solution that I hope will work

Changed in Callback.h 
added 
union CallBackData {
  char FileNameOrMsg[512];
  struct {
    char FileName[504];
    char *Data;
  }Xtra;
};


in the struct ZCallBackStruct 
char   FileNameOrMsg[512];  into
CallBackData CBData;

then in ZipBuilder.cpp in all statements were we had
cbr->FileNameOrMsg changed in
cbr->CBData.FileNameOrMsg

and finally in actioncode 14

char* Extra = cbr->CBData.Xtra.Data;

This is more or less what was in the Pascall version

Thanks for the help

Roger Aelbrecht
http://web.wanadoo.be/driehoeksw

Other related posts: