Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from paulijar/master
Browse files Browse the repository at this point in the history
Fixed parsing of non-regular files
  • Loading branch information
LukasReschke committed Sep 22, 2016
2 parents 89c8a68 + 382c015 commit 62f4de7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/getID3/getid3_handler.php
Expand Up @@ -84,7 +84,17 @@ protected function fread($bytes) {
if (!getid3_lib::intValueSupported($pos)) {
throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
}
return fread($this->getid3->fp, $bytes);

// System fread function may return less data than requested in case the file is not a regular local file.
// See http://php.net/manual/en/function.fread.php. Call it repeatedly in a loop if that is the case.
$contents = '';
do {
$part = fread($this->getid3->fp, $bytes);
$partLength = strlen($part);
$bytes -= $partLength;
$contents .= $part;
} while ($bytes > 0 && $partLength > 0);
return $contents;
}

protected function fseek($bytes, $whence=SEEK_SET) {
Expand Down

0 comments on commit 62f4de7

Please sign in to comment.