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 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
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 abstract class BaseTextFile extends BaseAbstractFile {
36 * Protected constructor
38 * @param $className Name of the class
41 protected function __construct (string $className) {
42 // Call parent constructor
43 parent::__construct($className);
47 * Determines seek position
49 * @return $seekPosition Current seek position
51 public function determineSeekPosition () {
52 // Not possible in text files
53 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
57 * Seek to given offset (default) or other possibilities as fseek() gives.
59 * @param $offset Offset to seek to (or used as "base" for other seeks)
60 * @param $whence Added to offset (default: only use offset to seek to)
61 * @return $status Status of file seek: 0 = success, -1 = failed
63 public function seek ($offset, $whence = SEEK_SET) {
64 // Not possible in text files
65 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEXT-FILE: offset=' . $offset . ',whence=' . $whence);
66 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
70 * Reads from a local or remote file
72 * @param $infoInstance An instance of a SplFileInfo class
73 * @return $array An array containing all read lines
74 * @throws InvalidArrayCountException If an array has not the expected size
75 * @throws InvalidMD5ChecksumException If two MD5 hashes did not match
77 public function loadFileContents (SplFileInfo $infoInstance) {
79 * This class (or its implementations) are special file readers/writers.
80 * There is no need to read/write the whole file.
82 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEXT-FILE: infoInstance=' . $infoInstance);
83 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);