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-2023 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 * Constructor (PHP5 style, required in some future version of PHP)
62 * reads translation file and fills translation input object properties
63 * @param string $filename path to file
64 * @return boolean false there is a problem with $filename
65 TODO: Constructors should not return anything.
67 function __construct($filename) {
68 // disable stat warnings for unreadable directories
69 if (@file_exists
($filename)) {
71 $this->_length
=filesize($filename);
73 $this->_fd
= fopen($filename,'rb');
75 $this->error
= 3; // Cannot read file, probably permissions
79 $this->error
= 2; // File doesn't exist
85 * Constructor (PHP4 style, kept for compatibility reasons)
86 * reads translation file and fills translation input object properties
87 * @param string $filename path to file
88 * @return boolean false there is a problem with $filename
89 TODO: Constructors should not return anything.
91 function FileReader($filename) {
92 return self
::__construct($filename);
96 * reads data from current position
97 * @param integer $bytes number of bytes to read
98 * @return string read data
100 function read($bytes) {
101 fseek($this->_fd
, $this->_pos
);
102 $data = fread($this->_fd
, $bytes);
103 $this->_pos
= ftell($this->_fd
);
109 * Moves to defined position in a file
110 * @param integer $pos position
111 * @return integer current position
113 function seekto($pos) {
114 fseek($this->_fd
, $pos);
115 $this->_pos
= ftell($this->_fd
);
120 * return current position
121 * @return integer current position
123 function currentpos() {
129 * @return integer file length
132 return $this->_length
;
136 * close translation file