src/lib/Herrera/Box/Extract.php
private function read($bytes)
    {
        $read = '';
        $total = $bytes;

        while (!feof($this->handle) && $bytes) {
            if (false === ($chunk = fread($this->handle, $bytes))) {
                throw new RuntimeException(
                    sprintf(
                        'Could not read %d bytes from "%s".',
                        $bytes,
                        $this->file
                    )
                );
            }

            $read .= $chunk;
            $bytes -= strlen($chunk);
        }

        if (($actual = strlen($read)) !== $total) {
            throw new RuntimeException(
                sprintf(
                    'Only read %d of %d in "%s".',
                    $actual,
                    $total,
                    $this->file
                )
            );
        }

        return $read;
    }
private function read($bytes)
    {
        $read = '';
        $total = $bytes;

        while (!feof($this->handle) && $bytes) {
            if (false === ($chunk = fread($this->handle, $bytes))) {
                throw new RuntimeException(
                    sprintf(
                        'Could not read %d bytes from "%s".',
                        $bytes,
                        $this->file
                    )
                );
            }

            $read .= $chunk;
            $bytes -= strlen($chunk);
        }

        if (($actual = strlen($read)) !== $total) {
            throw new RuntimeException(
                sprintf(
                    'Only read %d of %d in "%s".',
                    $actual,
                    $total,
                    $this->file
                )
            );
        }

        return $read;
    }
private function read ( $ bytes ) { $ read = '' ; $ total = $ bytes ; while ( ! feof ( $ this -> handle ) && $ bytes ) { if ( false === ( $ chunk = fread ( $ this -> handle , $ bytes ) ) ) { throw new RuntimeException ( sprintf ( 'Could not read %d bytes from "%s".' , $ bytes , $ this -> file ) ) ; } $ read .= $ chunk ; $ bytes -= strlen ( $ chunk ) ; } if ( ( $ actual = strlen ( $ read ) ) !== $ total ) { throw new RuntimeException ( sprintf ( 'Only read %d of %d in "%s".' , $ actual , $ total , $ this -> file ) ) ; } return $ read ; }
Reads the number of bytes from the file.

@param integer $bytes The number of bytes.

@return string The binary string read.

@throws RuntimeException If the read fails.
Reads the number of bytes from the file .