4 * Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
6 * This file is part of PHP-gettext.
8 * PHP-gettext is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PHP-gettext is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with PHP-gettext; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * @copyright © 2004-2007 The SquirrelMail Project Team
23 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
25 * @package squirrelmail
30 * Class that is used to read .mo files.
31 * @package squirrelmail
36 * Current position in file
51 * contains error codes
53 * 2 = File doesn't exist
60 * reads translation file and fills translation input object properties
61 * @param string $filename path to file
62 * @return boolean false there is a problem with $filename
64 function FileReader($filename) {
65 // disable stat warnings for unreadable directories
66 if (@file_exists
($filename)) {
68 $this->_length
=filesize($filename);
70 $this->_fd
= fopen($filename,'rb');
72 $this->error
= 3; // Cannot read file, probably permissions
76 $this->error
= 2; // File doesn't exist
82 * reads data from current position
83 * @param integer $bytes number of bytes to read
84 * @return string read data
86 function read($bytes) {
87 fseek($this->_fd
, $this->_pos
);
88 $data = fread($this->_fd
, $bytes);
89 $this->_pos
= ftell($this->_fd
);
95 * Moves to defined position in a file
96 * @param integer $pos position
97 * @return integer current position
99 function seekto($pos) {
100 fseek($this->_fd
, $pos);
101 $this->_pos
= ftell($this->_fd
);
106 * return current position
107 * @return integer current position
109 function currentpos() {
115 * @return integer file length
118 return $this->_length
;
122 * close translation file