Ahha, after some rethinking, I've dropped the append custom stream, as its not
really required.
And instead of using a custom in memory stream for handling the central
directory stream, just using tmpfile(), the application
error has disappeared.
Jared
> > >>Jared Williams wrote:
> > >>
> > >>>Hi,
> > >>> Short version, is there any way of listing all open
> > >>
> > >>resources from
> > >>
> > >>>within a PHP script? Think I may have a problem relating to
> > >>
> > >>the object/resource shutdown order within PHP, but cant see which
> > >>custom stream handler still has an open resource.
> >
> > why not let your zip class keep a list of opened streams (I can't
> > imagine that it's not doing that already) and write a
> function which
> > will output a list of 'registered' stream resources that are still
> > open [mis]using ftell() or feof() to check which streams are still
> > 'active'.
>
> There can only be one open stream at a time, when writing, as
> a stream writes to what will be the final zip file, and if
> they were not closed in the correct manner the resulting zip
> file wouldn't be valid.
>
> Perhaps I should explain in abit more detail how this is working.
>
> The ZipArchive creates two streams, one for the actual final
> zip, and the another for the central directories headers.
>
> When fputs($stream, '0123456789') occurs the data goes
> through 2 custom streams, and an optional filter.
>
> Zip custom stream -> optional compression filter -> Append
> custom stream -> final zip file.
>
> The Zip custom stream, handles writing the local header to
> the final zip file, calculating the compressed and
> uncompressed size, and crc (using hash extension). Like so
>
> function stream_write($data)
> {
> $r = fwrite($this->compressedStream, $data);
> $this->uncompressedSize += strlen($data);
> hash_update($this->hashContext, $data);
> return $r;
> }
>
> When the Zip custom stream is closed the zip local header is
> rewritten with the correct values, and a central directory
> header is written to the central directory stream. So if any
> resource was left open, then an invalid zip file would result.
>
> All $zip->close() has left todo, is append the central
> directory stream contents to the final zip, add a central end
> directory header and close both streams for a valid zip.
>
> Jared
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php