X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Finterfaces%2Fiterator%2Fclass_SeekableWritableFileIterator.php;h=d5f7c19252de07bbe8764cda26b200114dab4019;hp=1dde2c27235b52e32bc25e46cbefa1959e56d10d;hb=1295e7ab888e4ac1b7c1b92af58943e5dc72207b;hpb=8557e30c478c289b89a8dc241eb55b838aead662 diff --git a/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php b/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php index 1dde2c27..d5f7c192 100644 --- a/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php +++ b/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php @@ -39,13 +39,121 @@ interface SeekableWritableFileIterator extends SeekableIterator { function size (); /** - * Writes at given position by seeking to it. + * Reads given amount of bytes from file. * - * @param $seekPosition Seek position in file + * @param $bytes Amount of bytes to read + * @return $data Data read from file + */ + function read ($bytes); + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + */ + function analyzeFile (); + + /** + * Checks whether the file header is initialized + * + * @return $isInitialized Whether the file header is initialized + */ + function isFileHeaderInitialized (); + + /** + * Creates the assigned file + * + * @return void + */ + function createFileHeader (); + + /** + * Pre-allocates file (if enabled) with some space for later faster write access. + * + * @param $type Type of the file + * @return void + */ + function preAllocateFile ($type); + + /** + * Initializes counter for valid entries, arrays for damaged entries and + * an array for gap seek positions. If you call this method on your own, + * please re-analyze the file structure. So you are better to call + * analyzeFile() instead of this method. + * + * @return void + */ + function initCountersGapsArray (); + + /** + * Getter for header size + * + * @return $totalEntries Size of file header + */ + function getHeaderSize (); + + /** + * Setter for header size + * + * @param $headerSize Size of file header + * @return void + */ + function setHeaderSize ($headerSize); + + /** + * Getter for header array + * + * @return $totalEntries Size of file header + */ + function getHeader (); + + /** + * Setter for header + * + * @param $header Array for a file header + * @return void + */ + function setHeader (array $header); + + /** + * Updates seekPosition attribute from file to avoid to much access on file. + * + * @return void + */ + function updateSeekPosition (); + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + function getCounter (); + + /** + * "Getter" for file size + * + * @return $fileSize Size of currently loaded file + */ + function getFileSize (); + + /** + * Writes data at given position + * + * @param $seekPosition Seek position * @param $data Data to be written + * @param $flushHeader Whether to flush the header (default: flush) * @return void */ - function writeAtPosition ($seedPosition, $data); + function writeData ($seekPosition, $data, $flushHeader = TRUE); + + /** + * Getter for seek position + * + * @return $seekPosition Current seek position (stored here in object) + */ + function getSeekPosition (); } // [EOF]