Changeset 2394 for trunk/wp-includes/streams.php
- Timestamp:
- 02/28/2005 04:31:01 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/streams.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/streams.php
r1080 r2394 1 1 <?php 2 2 /* 3 Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.3 Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>. 4 4 5 5 This file is part of PHP-gettext. … … 104 104 105 105 function read($bytes) { 106 fseek($this->_fd, $this->_pos); 107 $data = fread($this->_fd, $bytes); 108 $this->_pos = ftell($this->_fd); 109 110 return $data; 106 if ($bytes) { 107 fseek($this->_fd, $this->_pos); 108 $data = fread($this->_fd, $bytes); 109 $this->_pos = ftell($this->_fd); 110 111 return $data; 112 } else return ''; 111 113 } 112 114 … … 131 133 } 132 134 135 // Preloads entire file in memory first, then creates a StringReader 136 // over it (it assumes knowledge of StringReader internals) 137 class CachedFileReader extends StringReader { 138 function CachedFileReader($filename) { 139 if (file_exists($filename)) { 140 141 $length=filesize($filename); 142 $fd = fopen($filename,'rb'); 143 144 if (!$fd) { 145 $this->error = 3; // Cannot read file, probably permissions 146 return false; 147 } 148 $this->_str = fread($fd, $length); 149 fclose($fd); 150 151 } else { 152 $this->error = 2; // File doesn't exist 153 return false; 154 } 155 } 156 } 157 158 133 159 ?>
Note: See TracChangeset
for help on using the changeset viewer.