648453d6ab1388f6122e451c4ddb5a1960674f3c
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., 51 Franklin St, Fifth Floor, Boston,
23 * @copyright © 2004-2009 The SquirrelMail Project Team
24 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
26 * @package squirrelmail
31 * Class that is used to read .mo files.
32 * @package squirrelmail
37 * Current position in file
52 * contains error codes
54 * 2 = File doesn't exist
61 * reads translation file and fills translation input object properties
62 * @param string $filename path to file
63 * @return boolean false there is a problem with $filename
65 function FileReader($filename) {
66 // disable stat warnings for unreadable directories
67 if (@file_exists
($filename)) {
69 $this->_length
=filesize($filename);
71 $this->_fd
= fopen($filename,'rb');
73 $this->error
= 3; // Cannot read file, probably permissions
77 $this->error
= 2; // File doesn't exist
83 * reads data from current position
84 * @param integer $bytes number of bytes to read
85 * @return string read data
87 function read($bytes) {
88 fseek($this->_fd
, $this->_pos
);
89 $data = fread($this->_fd
, $bytes);
90 $this->_pos
= ftell($this->_fd
);
96 * Moves to defined position in a file
97 * @param integer $pos position
98 * @return integer current position
100 function seekto($pos) {
101 fseek($this->_fd
, $pos);
102 $this->_pos
= ftell($this->_fd
);
107 * return current position
108 * @return integer current position
110 function currentpos() {
116 * @return integer file length
119 return $this->_length
;
123 * close translation file