[pmwiki-users] Re: Questions on release 2.0.0 (PageStore class)
Patrick R. Michaud
pmichaud at pobox.com
Sun Sep 4 10:53:36 CDT 2005
On Sat, Sep 03, 2005 at 09:37:53PM +0000, Karl Loncarek wrote:
> > So it seems to me that in order for gzpagestore to provide this
> > level of reliability, it would have to re-read and uncompress the file
> > that was just written to check its contents and length. That sort
> > of check could probably be provided by default, or as an option.
>
> That sound reasonable to me, but how to do this? I would integrate this,
> but I'm no expert in PHP and especially in OOP.
>
> Can I call the read function from within the write function?
> How would this have to look like?
Instead of the $s = $s && (filesize("$pagefile,new") > $sz * 0.95) line,
try something like:
$fp = gzopen("$pagefile,new", 'r');
$len = $sz * 0.95;
while ($len > 0 && !gzeof($fp))
{ $x = gzread($fp, 4096); $len -= strlen($x); }
gzclose($fp);
$s = $s && ($len <= 0);
which reads back the file just written, returning success if at least
95% of the original length is recovered.
Pm
More information about the pmwiki-users
mailing list