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);
65 $this->_fd
= fopen($filename,'rb');
67 $this->error
= 3; // Cannot read file, probably permissions
71 $this->error
= 2; // File doesn't exist
77 * reads data from current position
78 * @param integer $bytes number of bytes to read
79 * @return string read data
81 function read($bytes) {
82 fseek($this->_fd
, $this->_pos
);
83 $data = fread($this->_fd
, $bytes);
84 $this->_pos
= ftell($this->_fd
);
90 * Moves to defined position in a file
91 * @param integer $pos position
92 * @return integer current position
94 function seekto($pos) {
95 fseek($this->_fd
, $pos);
96 $this->_pos
= ftell($this->_fd
);
101 * return current position
102 * @return integer current position
104 function currentpos() {
110 * @return integer file length
113 return $this->_length
;
117 * close translation file