5 * @author Roland Haeder <webmaster@ship-simu.org>
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
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.
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.
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/>.
24 class StackFile extends BaseFile implements InputOutputPointer {
26 * Protected constructor
30 protected function __construct () {
31 // Call parent constructor
32 parent::__construct(__CLASS__);
36 * Creates an instance of this File class and prepares it for usage
38 * @param $fileName Name of the stack file
39 * @return $fileInstance An instance of this File class
41 public final static function createStackFile ($fileName) {
43 $fileInstance = new StackFile();
45 // Init this abstract file
46 $fileInstance->initFile($fileName);
48 // Return the prepared instance
53 * Determines seek position
55 * @return $seekPosition Current seek position
58 public final function determineSeekPosition () {
59 $this->partialStub('Unfinished method.');
63 * Seek to given offset (default) or other possibilities as fseek() gives.
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
70 public function seek ($offset, $whence = SEEK_SET) {
71 $this->partialStub('Unfinished method.');
77 * @return $size Size (in bytes) of file
78 * @todo Handle seekStatus
81 public function size () {
82 $this->partialStub('Unfinished method.');
86 * Read data a file pointer
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
93 public function readFromFile () {
94 $this->partialStub('Unfinished method.');
98 * Reads given amount of bytes from file.
100 * @param $bytes Amount of bytes to read
101 * @return $data Data read from file
103 public function read ($bytes) {
104 $this->partialStub('bytes=' . $bytes);
108 * Write data to a file pointer
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
117 public function writeToFile ($dataStream) {
118 $this->partialStub('dataStream=' . $dataStream);
122 * Rewinds to the beginning of the file
124 * @return $status Status of this operation
126 public function rewind () {
127 $this->partialStub('Unfinished method.');