c65bed4d3757dc3a4a911a7b9a0652e2ff4173dc
[core.git] / inc / classes / main / file_directories / index / class_IndexFile.php
1 <?php
2 /**
3  * An index file class
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 class IndexFile extends BaseFile implements InputOutputPointer {
25         /**
26          * Protected constructor
27          *
28          * @return      void
29          */
30         protected function __construct () {
31                 // Call parent constructor
32                 parent::__construct(__CLASS__);
33         }
34
35         /**
36          * Creates an instance of this File class and prepares it for usage
37          *
38          * @param       $fileName               Name of the index file
39          * @return      $fileInstance   An instance of this File class
40          */
41         public final static function createIndexFile ($fileName) {
42                 // Get a new instance
43                 $fileInstance = new IndexFile();
44
45                 // Init this abstract file
46                 $fileInstance->initFile($fileName);
47
48                 // Return the prepared instance
49                 return $fileInstance;
50         }
51
52         /**
53          * Determines seek position
54          *
55          * @return      $seekPosition   Current seek position
56          * @todo        0% done
57          */
58         public final function determineSeekPosition () {
59                 $this->partialStub('Unfinished method.');
60         }
61
62         /**
63          * Seek to given offset (default) or other possibilities as fseek() gives.
64          *
65          * @param       $offset         Offset to seek to (or used as "base" for other seeks)
66          * @param       $whence         Added to offset (default: only use offset to seek to)
67          * @return      $status         Status of file seek: 0 = success, -1 = failed
68          * @todo        0% done
69          */
70         public function seek ($offset, $whence = SEEK_SET) {
71                 $this->partialStub('Unfinished method.');
72         }
73
74         /**
75          * Size of this file
76          *
77          * @return      $size   Size (in bytes) of file
78          * @todo        Handle seekStatus
79          * @todo        0% done
80          */
81         public function size () {
82                 $this->partialStub('Unfinished method.');
83         }
84
85         /**
86          * Read data a file pointer
87          *
88          * @return      mixed   The result of fread()
89          * @throws      NullPointerException    If the file pointer instance
90          *                                                                      is not set by setPointer()
91          * @throws      InvalidResourceException        If there is being set
92          */
93         public function readFromFile () {
94                 $this->partialStub('Unfinished method.');
95         }
96
97         /**
98          * Reads given amount of bytes from file.
99          *
100          * @param       $bytes  Amount of bytes to read
101          * @return      $data   Data read from file
102          */
103         public function read ($bytes) {
104                 $this->partialStub('bytes=' . $bytes);
105         }
106
107         /**
108          * Write data to a file pointer
109          *
110          * @param       $dataStream             The data stream we shall write to the file
111          * @return      mixed                   Number of writes bytes or FALSE on error
112          * @throws      NullPointerException    If the file pointer instance
113          *                                                                      is not set by setPointer()
114          * @throws      InvalidResourceException        If there is being set
115          *                                                                                      an invalid file resource
116          */
117         public function writeToFile ($dataStream) {
118                 $this->partialStub('dataStream=' . $dataStream);
119         }
120
121         /**
122          * Rewinds to the beginning of the file
123          *
124          * @return      $status         Status of this operation
125          */
126         public function rewind () {
127                 $this->partialStub('Unfinished method.');
128         }
129 }
130
131 // [EOF]
132 ?>