3 namespace Org\Mxchange\CoreFramework\Filesystem\File;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
7 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
13 * A general text file class
15 * @author Roland Haeder <webmaster@ship-simu.org>
17 <<<<<<< HEAD:framework/main/classes/file_directories/text/class_BaseTextFile.php
18 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
20 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
21 >>>>>>> Some updates::inc/main/classes/file_directories/text/class_BaseTextFile.php
22 * @license GNU GPL 3.0 or any newer version
23 * @link http://www.ship-simu.org
25 * This program is free software: you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation, either version 3 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program. If not, see <http://www.gnu.org/licenses/>.
38 abstract class BaseTextFile extends BaseAbstractFile {
40 * Protected constructor
42 * @param $className Name of the class
45 protected function __construct ($className) {
46 // Call parent constructor
47 parent::__construct($className);
51 * Determines seek position
53 * @return $seekPosition Current seek position
55 public function determineSeekPosition () {
56 // Not possible in text files
57 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
61 * Seek to given offset (default) or other possibilities as fseek() gives.
63 * @param $offset Offset to seek to (or used as "base" for other seeks)
64 * @param $whence Added to offset (default: only use offset to seek to)
65 * @return $status Status of file seek: 0 = success, -1 = failed
67 public function seek ($offset, $whence = SEEK_SET) {
68 // Not possible in text files
69 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
70 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
74 * Reads from a local or remote file
76 * @param $infoInstance An instance of a SplFileInfo class
77 * @return $array An array containing all read lines
78 * @throws InvalidArrayCountException If an array has not the expected size
79 * @throws InvalidMD5ChecksumException If two MD5 hashes did not match
81 public function loadFileContents (SplFileInfo $infoInstance) {
83 * This class (or its implementations) are special file readers/writers.
84 * There is no need to read/write the whole file.
86 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] infoInstance=' . $infoInstance);
87 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);