Bug #16689 Updated: bzread has no reliable way of detecting eof

From: Date: Thu, 18 Apr 2002 22:41:10 +0000
Subject: Bug #16689 Updated: bzread has no reliable way of detecting eof
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-5343@lists.php.net to get a copy of this message
ID: 16689 Updated by: wez@php.net Reported By: joshbuddy@hotmail.com Status: Closed Bug Type: Bzip2 Related PHP Version: 4.1.2 New Comment: Err, scratch that last comment; the only way to detect eof for bzip streams is to keep reading it. feof will always return false for bz2. Your bzread or fread call should return false when no more data can be read. while(($string = bzread($bzfile, 4096)) !== false) { ... } should do what you want. Previous Comments: ------------------------------------------------------------------------ [2002-04-18 18:35:27] wez@php.net Try a recent CVS snapshot; you can now use feof on bz handles. Reopen this report if it doesn't work for you :-) ------------------------------------------------------------------------ [2002-04-18 17:29:05] joshbuddy@hotmail.com obviously feof will not work on a Bz file handle (though it would be nice if it did) the only way i could find it detect the end in a loop (where you would be slurping in the whole file) is: // open the file ... $bzfile $data=""; $string=bzread($bzfile,4096); while ($string!=str_repeat("\0",4096)) { $data.=$string; $string=bzread($bzfile,4096); } a better mechanism for eof detection is needed ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16689&edit=1

« previous php.bugs (#5343) next »