Bump php-gettext to version 1.0.3. http://mosquito.wordpress.org/view.php?id=1001 Mad props to Nico Kaiser.
git-svn-id: http://svn.automattic.com/wordpress/trunk@2394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
|
||||
Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>.
|
||||
|
||||
This file is part of PHP-gettext.
|
||||
|
||||
@@ -103,11 +103,13 @@ class FileReader {
|
||||
}
|
||||
|
||||
function read($bytes) {
|
||||
fseek($this->_fd, $this->_pos);
|
||||
$data = fread($this->_fd, $bytes);
|
||||
$this->_pos = ftell($this->_fd);
|
||||
|
||||
return $data;
|
||||
if ($bytes) {
|
||||
fseek($this->_fd, $this->_pos);
|
||||
$data = fread($this->_fd, $bytes);
|
||||
$this->_pos = ftell($this->_fd);
|
||||
|
||||
return $data;
|
||||
} else return '';
|
||||
}
|
||||
|
||||
function seekto($pos) {
|
||||
@@ -130,4 +132,28 @@ 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) {
|
||||
if (file_exists($filename)) {
|
||||
|
||||
$length=filesize($filename);
|
||||
$fd = fopen($filename,'rb');
|
||||
|
||||
if (!$fd) {
|
||||
$this->error = 3; // Cannot read file, probably permissions
|
||||
return false;
|
||||
}
|
||||
$this->_str = fread($fd, $length);
|
||||
fclose($fd);
|
||||
|
||||
} else {
|
||||
$this->error = 2; // File doesn't exist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user