~canonical-sysadmins/wordpress/4.7

« back to all changes in this revision

Viewing changes to wp-includes/pomo/streams.php

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:04:26 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: nick.moffitt@canonical.com-20150115110426-5stm1p14cfnxrtme
New Upstream Version 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
                return unpack($endian_letter.$count, $bytes);
59
59
        }
60
60
 
61
 
 
 
61
        /**
 
62
         * @param string $string
 
63
         * @param int    $start
 
64
         * @param int    $length
 
65
         * @return string
 
66
         */
62
67
        function substr($string, $start, $length) {
63
68
                if ($this->is_overloaded) {
64
69
                        return mb_substr($string, $start, $length, 'ascii');
67
72
                }
68
73
        }
69
74
 
 
75
        /**
 
76
         * @param string $string
 
77
         * @return int
 
78
         */
70
79
        function strlen($string) {
71
80
                if ($this->is_overloaded) {
72
81
                        return mb_strlen($string, 'ascii');
75
84
                }
76
85
        }
77
86
 
 
87
        /**
 
88
         * @param string $string
 
89
         * @param int    $chunk_size
 
90
         * @return array
 
91
         */
78
92
        function str_split($string, $chunk_size) {
79
93
                if (!function_exists('str_split')) {
80
94
                        $length = $this->strlen($string);
104
118
 
105
119
if ( !class_exists( 'POMO_FileReader' ) ):
106
120
class POMO_FileReader extends POMO_Reader {
 
121
 
 
122
        /**
 
123
         * @param string $filename
 
124
         */
107
125
        function POMO_FileReader($filename) {
108
126
                parent::POMO_Reader();
109
127
                $this->_f = fopen($filename, 'rb');
110
128
        }
111
129
 
 
130
        /**
 
131
         * @param int $bytes
 
132
         */
112
133
        function read($bytes) {
113
134
                return fread($this->_f, $bytes);
114
135
        }
115
136
 
 
137
        /**
 
138
         * @param int $pos
 
139
         * @return boolean
 
140
         */
116
141
        function seekto($pos) {
117
142
                if ( -1 == fseek($this->_f, $pos, SEEK_SET)) {
118
143
                        return false;
157
182
                $this->_pos = 0;
158
183
        }
159
184
 
160
 
 
 
185
        /**
 
186
         * @param string $bytes
 
187
         * @return string
 
188
         */
161
189
        function read($bytes) {
162
190
                $data = $this->substr($this->_str, $this->_pos, $bytes);
163
191
                $this->_pos += $bytes;
165
193
                return $data;
166
194
        }
167
195
 
 
196
        /**
 
197
         * @param int $pos
 
198
         * @return int
 
199
         */
168
200
        function seekto($pos) {
169
201
                $this->_pos = $pos;
170
202
                if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);