3 * Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
5 * This file is part of PHP-gettext.
7 * PHP-gettext is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * PHP-gettext is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with PHP-gettext; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * @package squirrelmail
26 * Class that is used to read .mo files.
27 * @package squirrelmail
32 * Current position in file
47 * contains error codes
49 * 2 = File doesn't exist
56 * reads translation file and fills translation input object properties
57 * @param string $filename path to file
58 * @return boolean false there is a problem with $filename
60 function FileReader($filename) {
61 if (file_exists($filename)) {
63 $this->_length
=filesize($filename);
64 error_log($this->_length
);
66 $this->_fd
= fopen($filename,'rb');
68 $this->error
= 3; // Cannot read file, probably permissions
72 $this->error
= 2; // File doesn't exist
78 * reads data from current position
79 * @param integer $bytes number of bytes to read
80 * @return string read data
82 function read($bytes) {
83 fseek($this->_fd
, $this->_pos
);
84 $data = fread($this->_fd
, $bytes);
85 $this->_pos
= ftell($this->_fd
);
91 * Moves to defined position in a file
92 * @param integer $pos position
93 * @return integer current position
95 function seekto($pos) {
96 fseek($this->_fd
, $pos);
97 $this->_pos
= ftell($this->_fd
);
102 * return current position
103 * @return integer current position
105 function currentpos() {
111 * @return integer file length
114 return $this->_length
;
118 * close translation file