[delphizip] Problem using ExtractFileToStream

  • From: "Trueman, Christopher" <ctrueman@xxxxxxxxxxxxxxx>
  • To: <delphizip@xxxxxxxxxxxxx>
  • Date: Wed, 4 Oct 2006 15:33:53 -0700

I'm working with ZIP archives that contains ZIP archives and so on down
for a number of levels.  Dumping the DirEntry[...]^.FileName might look
like:

FILES.TXT
DIR/A_ZIP_FILE.ZIP

What I want to do is extract the DIR/A_ZIP_FILE.ZIP so that I can read
its contents.  I'm using code like this:

  zf :=3D TZipMaster.Create(nil);

  try
    zf.Trace :=3D true;
    zf.Verbose :=3D true;
    zf.OnMessage :=3D OnMessage;
    zf.ZipFileName :=3D filename;

    for iii :=3D 0 to zf.Count - 1 do
    begin
      de :=3D zf.DirEntry[iii];
      fn :=3D de^.FileName;

      FireOnProgress('Found: ' + fn);

        // Use the file suffix to determine if this is a ZIP in a ZIP.
      if IsZipFile(fn) then
      begin
        // A ZIP within a ZIP, we need to extract to a temporary
        // location before recursively scanning.
        // For entries like BUILD/A_ZIP_FILE.ZIP, zs is not getting
assigned!
        zs :=3D zf.ExtractFileToStream(fn);

        if Assigned(zs) then
        begin
          tn :=3D GetTempPathName('SCA');
          fs :=3D TFileStream.Create(tn, fmCreate);

          try
            fs.CopyFrom(zs, zs.Size);
          finally
            FreeAndNil(fs);
          end;

          // Scan the extracted ZIP - true means skip ZIP test on entry.
          InternalScan(tn, true);
        end;
      end;
    end;
  finally
    FreeAndNil(zf);
  end;

My problem is that the stream returned by ExtractFileToStream is always
nil for entries of the type DIR/A_ZIP_FILE.ZIP

The trace messages look like:

Skipped DIR/A_ZIP_FILE.ZIP 8

Any ideas?



Chris.

_______________________________________________________
The contents of this e-mail are intended for the named addressee only. =
It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or =
disclose
it to anyone else. If you received it in error please notify the sender=20
immediately, and then destroy it.

-----------
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: