Some updates:
[core.git] / framework / main / classes / file_directories / text / class_BaseTextFile.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Filesystem\File;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
7 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
8
9 // Import SPL stuff
10 use \SplFileInfo;
11
12 /**
13  * A general text file class
14  *
15  * @author              Roland Haeder <webmaster@ship-simu.org>
16  * @version             0.0.0
17 <<<<<<< HEAD:framework/main/classes/file_directories/text/class_BaseTextFile.php
18  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
19 =======
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
24  *
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.
29  *
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.
34  *
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/>.
37  */
38 abstract class BaseTextFile extends BaseAbstractFile {
39         /**
40          * Protected constructor
41          *
42          * @param       $className      Name of the class
43          * @return      void
44          */
45         protected function __construct ($className) {
46                 // Call parent constructor
47                 parent::__construct($className);
48         }
49
50         /**
51          * Determines seek position
52          *
53          * @return      $seekPosition   Current seek position
54          */
55         public function determineSeekPosition () {
56                 // Not possible in text files
57                 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
58         }
59
60         /**
61          * Seek to given offset (default) or other possibilities as fseek() gives.
62          *
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
66          */
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);
71         }
72
73         /**
74          * Reads from a local or remote file
75          *
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
80          */
81         public function loadFileContents (SplFileInfo $infoInstance) {
82                 /*
83                  * This class (or its implementations) are special file readers/writers.
84                  * There is no need to read/write the whole file.
85                  */
86                 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] infoInstance=' . $infoInstance);
87                 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
88         }
89
90 }