|
|
@ -49,11 +49,15 @@ class StringReader { |
|
|
|
var $_pos; |
|
|
|
var $_str; |
|
|
|
|
|
|
|
function StringReader($str='') { |
|
|
|
function __construct($str='') { |
|
|
|
$this->_str = $str; |
|
|
|
$this->_pos = 0; |
|
|
|
} |
|
|
|
|
|
|
|
function StringReader($str='') { |
|
|
|
self::__construct($str); |
|
|
|
} |
|
|
|
|
|
|
|
function read($bytes) { |
|
|
|
$data = substr($this->_str, $this->_pos, $bytes); |
|
|
|
$this->_pos += $bytes; |
|
|
@ -86,7 +90,7 @@ class FileReader { |
|
|
|
var $_fd; |
|
|
|
var $_length; |
|
|
|
|
|
|
|
function FileReader($filename) { |
|
|
|
function __construct($filename) { |
|
|
|
if (file_exists($filename)) { |
|
|
|
|
|
|
|
$this->_length=filesize($filename); |
|
|
@ -102,6 +106,10 @@ class FileReader { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function FileReader($filename) { |
|
|
|
self::__construct($filename); |
|
|
|
} |
|
|
|
|
|
|
|
function read($bytes) { |
|
|
|
if ($bytes) { |
|
|
|
fseek($this->_fd, $this->_pos); |
|
|
@ -143,7 +151,7 @@ class FileReader { |
|
|
|
// Preloads entire file in memory first, then creates a StringReader |
|
|
|
// over it (it assumes knowledge of StringReader internals) |
|
|
|
class CachedFileReader extends StringReader { |
|
|
|
function CachedFileReader($filename) { |
|
|
|
function __construct($filename) { |
|
|
|
if (file_exists($filename)) { |
|
|
|
|
|
|
|
$length=filesize($filename); |
|
|
@ -161,6 +169,10 @@ class CachedFileReader extends StringReader { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function CachedFileReader($filename) { |
|
|
|
self::__construct($filename); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|