FILE readAll & rewind method's
| From: | b | Date: | Thu, 10 Apr 2003 18:13:12 +0000 |
| Subject: | FILE readAll & rewind method's | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-15103@lists.php.net to get a copy of this message | ||
Hi,
I found the following problem in
| File | 1.0.3 | stable |File.php when calling FILE:readAll($filename ); more than one time after eachother, only the first time the file contents is returned, the pother time an empty string will be returned. I think it has to do with the fact that is is not rewinded in readAll, so the filepointer is still pointer to the end of the file.,, This is a bug right? solution: though this only seems to work with a filepointer that has a FILE_MODE_READ set. Seem logical for a readAll
function readAll($filename, $lock = false)
{
FILE::rewind( $filename, FILE_MODE_READ );
$file = '';
while (($tmp = File::read($filename, FILE_DEFAULT_READSIZE, $lock)) !== FALSE) {
if (PEAR::isError($tmp)) {
return $tmp;
}
$file .= $tmp;
}
return $file;
}
hope this will be fixed in a future release of the pear package
thx Bas Kamer