X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..341dfbb66f24f5145174c373267f889c31615cc5:/wp-includes/pomo/streams.php diff --git a/wp-includes/pomo/streams.php b/wp-includes/pomo/streams.php index 289cc785..efaffa5a 100644 --- a/wp-includes/pomo/streams.php +++ b/wp-includes/pomo/streams.php @@ -3,26 +3,26 @@ * Classes, which help reading streams of data from files. * Based on the classes from Danilo Segan * - * @version $Id: streams.php 406 2010-02-07 11:10:24Z nbachiyski $ + * @version $Id: streams.php 597 2011-01-16 20:14:36Z nbachiyski $ * @package pomo * @subpackage streams */ if ( !class_exists( 'POMO_Reader' ) ): class POMO_Reader { - + var $endian = 'little'; var $_post = ''; - + function POMO_Reader() { $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr'); $this->_pos = 0; } - + /** * Sets the endianness of the file. * - * @param string $endian 'big' or 'little' + * @param $endian string 'big' or 'little' */ function setEndian($endian) { $this->endian = $endian; @@ -57,8 +57,8 @@ class POMO_Reader { $endian_letter = ('big' == $this->endian)? 'N' : 'V'; return unpack($endian_letter.$count, $bytes); } - - + + function substr($string, $start, $length) { if ($this->is_overloaded) { return mb_substr($string, $start, $length, 'ascii'); @@ -66,7 +66,7 @@ class POMO_Reader { return substr($string, $start, $length); } } - + function strlen($string) { if ($this->is_overloaded) { return mb_strlen($string, 'ascii'); @@ -74,7 +74,7 @@ class POMO_Reader { return strlen($string); } } - + function str_split($string, $chunk_size) { if (!function_exists('str_split')) { $length = $this->strlen($string); @@ -86,8 +86,8 @@ class POMO_Reader { return str_split( $string, $chunk_size ); } } - - + + function pos() { return $this->_pos; } @@ -95,7 +95,7 @@ class POMO_Reader { function is_resource() { return true; } - + function close() { return true; } @@ -106,13 +106,13 @@ if ( !class_exists( 'POMO_FileReader' ) ): class POMO_FileReader extends POMO_Reader { function POMO_FileReader($filename) { parent::POMO_Reader(); - $this->_f = fopen($filename, 'r'); + $this->_f = fopen($filename, 'rb'); } - + function read($bytes) { return fread($this->_f, $bytes); } - + function seekto($pos) { if ( -1 == fseek($this->_f, $pos, SEEK_SET)) { return false; @@ -120,19 +120,19 @@ class POMO_FileReader extends POMO_Reader { $this->_pos = $pos; return true; } - + function is_resource() { return is_resource($this->_f); } - + function feof() { return feof($this->_f); } - + function close() { return fclose($this->_f); } - + function read_all() { $all = ''; while ( !$this->feof() ) @@ -148,9 +148,9 @@ if ( !class_exists( 'POMO_StringReader' ) ): * of a physical file. */ class POMO_StringReader extends POMO_Reader { - + var $_str = ''; - + function POMO_StringReader($str = '') { parent::POMO_Reader(); $this->_str = $str; @@ -178,7 +178,7 @@ class POMO_StringReader extends POMO_Reader { function read_all() { return $this->substr($this->_str, $this->_pos, $this->strlen($this->_str)); } - + } endif;