3 namespace Org\Mxchange\CoreFramework\Filesystem;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
11 * @author Roland Haeder <webmaster@ship-simu.org>
13 <<<<<<< HEAD:framework/main/interfaces/block/class_Block.php
14 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
17 >>>>>>> Some updates::inc/main/interfaces/block/class_Block.php
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.ship-simu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 interface Block extends FrameworkInterface {
36 * Reads the file header
40 function readFileHeader ();
43 * Flushes the file header
47 function flushFileHeader ();
50 * Determines whether the EOF has been reached
52 * @return $isEndOfFileReached Whether the EOF has been reached
54 function isEndOfFileReached ();
57 * Initializes counter for valid entries, arrays for damaged entries and
58 * an array for gap seek positions. If you call this method on your own,
59 * please re-analyze the file structure. So you are better to call
60 * analyzeFile() instead of this method.
64 function initCountersGapsArray ();
67 * Getter for header size
69 * @return $totalEntries Size of file header
71 function getHeaderSize ();
74 * Setter for header size
76 * @param $headerSize Size of file header
79 function setHeaderSize ($headerSize);
82 * Getter for header array
84 * @return $totalEntries Size of file header
86 function getHeader ();
91 * @param $header Array for a file header
94 function setHeader (array $header);
97 * Updates seekPosition attribute from file to avoid to much access on file.
101 function updateSeekPosition ();
104 * Getter for total entries
106 * @return $totalEntries Total entries in this file
108 function getCounter ();
111 * "Getter" for file size
113 * @return $fileSize Size of currently loaded file
115 function getFileSize ();
118 * Writes given value to the file and returns a hash and gap position for it
120 * @param $groupId Group identifier
121 * @param $value Value to be added to the stack
122 * @return $data Hash and gap position
124 function writeValueToFile ($groupId, $rawData);
127 * Writes given raw data to the file and returns a gap position and length
129 * @param $groupId Group identifier
130 * @param $hash Hash from encoded value
131 * @param $encoded Encoded value to be written to the file
132 * @return $data Gap position and length of the raw data
134 function writeDataToFreeGap ($groupId, $hash, $encoded);
137 * Writes data at given position
139 * @param $seekPosition Seek position
140 * @param $data Data to be written
141 * @param $flushHeader Whether to flush the header (default: flush)
144 function writeData ($seekPosition, $data, $flushHeader = true);
147 * Searches for next suitable gap the given length of data can fit in
148 * including padding bytes.
150 * @param $length Length of raw data
151 * @return $seekPosition Found next gap's seek position
153 function searchNextGap ($length);