[delphizip] Re: Question: Detect ZIP data using QueryZip

  • From: R Peters <rpeters@xxxxxxxxxxxxx>
  • To: delphizip@xxxxxxxxxxxxx
  • Date: Mon, 4 Oct 2010 17:32:26 +1100

First, you don't need a ZipMaster component to call QueryZip - it is defined
in ZMUtils19.pas and was only made available as a method for convenience.
For a zip (or sfx) to be valid zqbHasEOC must be set, an sfx will have
zqbStartEXE set as well.
Zip64 may or may not zqbHasEOC64 set (if it is set zqbHasLoc64 must also be
set).
zqbHasCentral signifies that the first central entry exists and if that is
set zqbHasLocal signifies that the first central entry points to a valid
local header - these may not be set on multi-part zips (depending upon where
the splits are).

Hopefully this helps.
Russell Peters

On Mon, Oct 4, 2010 at 4:12 AM, Daniel Marschall <uni@xxxxxxxxxxxxxxxxxxx>wrote:

> Hello.
>
> I need a function that checks if a file has ZIP-data and is (probably)
> extractable. I want to allow ZIP-SFXs and native ZIP files.
>
> Here is my current function:
>
>
> function IsExtractable(AFilename: string): boolean;
> var
>  q: integer;
>  uz: TZipMaster19;
> begin
>  uz := TZipMaster19.Create(nil);
>  try
>    q := uz.QueryZip(AFilename);
>    result := true;
>    if (q and zqbHasLocal) <> zqbHasLocal then result := false;
>    if (q and zqbHasCentral) <> zqbHasCentral then result := false;
>    if ((q and zqbHasEOC) <> zqbHasEOC) and
>       ((q and zqbHasEOC64) <> zqbHasEOC64) then result := false;
>  finally
>    uz.Free;
>  end;
> end;
>
>
> My questions:
> - In a ZIP64 file (I never had used one), is zqbHasEOC64 available and
> zqbHasEOC not? Or are both bits, zqbHasEOC and zqbHasEOC64 set?
> - If zqbHasEOC64 is set, is zqbHasLoc64 then required too?
> - Any suggestions how to improve that function?
>
> Regards
> Daniel Marschall
>
>
> -----------
> To unsubscribe from this list, send an empty e-mail
> message to:
>  delphizip-request@xxxxxxxxxxxxx
> and put the word unsubscribe in the subject.
>


-----------
To unsubscribe from this list, send an empty e-mail 
message to:
  delphizip-request@xxxxxxxxxxxxx 
and put the word unsubscribe in the subject.

Other related posts: