From: Roland Haeder <roland@mxchange.org>
Date: Wed, 21 May 2014 19:45:48 +0000 (+0200)
Subject: Moved all to BaseFile. This currently makes all inheriting classes "lifeless"
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=382d1f5cddbc8c210cbc399476820415a22ba474;p=core.git

Moved all to BaseFile. This currently makes all inheriting classes "lifeless"
but this will change in the future.

Signed-off-by: Roland Häder <roland@mxchange.org>
---

diff --git a/inc/classes/main/file_directories/class_BaseFile.php b/inc/classes/main/file_directories/class_BaseFile.php
index a2a3432a..f286fe3a 100644
--- a/inc/classes/main/file_directories/class_BaseFile.php
+++ b/inc/classes/main/file_directories/class_BaseFile.php
@@ -51,6 +51,26 @@ class BaseFile extends BaseFrameworkSystem {
 		parent::__destruct();
 	}
 
+	/**
+	 * Setter for file name
+	 *
+	 * @param	$fileName	The new file name
+	 * @return	void
+	 */
+	protected final function setFileName ($fileName) {
+		$fileName = (string) $fileName;
+		$this->fileName = $fileName;
+	}
+
+	/**
+	 * Getter for file name
+	 *
+	 * @return	$fileName	The current file name
+	 */
+	public final function getFileName () {
+		return $this->fileName;
+	}
+
 	/**
 	 * Initializes this file class
 	 *
@@ -80,23 +100,78 @@ class BaseFile extends BaseFrameworkSystem {
 	}
 
 	/**
-	 * Setter for file name
+	 * Determines seek position
 	 *
-	 * @param	$fileName	The new file name
-	 * @return	void
+	 * @return	$seekPosition	Current seek position
 	 */
-	protected final function setFileName ($fileName) {
-		$fileName = (string) $fileName;
-		$this->fileName = $fileName;
+	public final function determineSeekPosition () {
+		return $this->getPointerInstance()->determineSeekPosition();
 	}
 
 	/**
-	 * Getter for file name
+	 * Seek to given offset (default) or other possibilities as fseek() gives.
 	 *
-	 * @return	$fileName	The current file name
+	 * @param	$offset		Offset to seek to (or used as "base" for other seeks)
+	 * @param	$whence		Added to offset (default: only use offset to seek to)
+	 * @return	$status		Status of file seek: 0 = success, -1 = failed
 	 */
-	public final function getFileName () {
-		return $this->fileName;
+	public function seek ($offset, $whence = SEEK_SET) {
+		return $this->getPointerInstance()->seek($offset, $whence);
+	}
+
+	/**
+	 * Size of this file
+	 *
+	 * @return	$size	Size (in bytes) of file
+	 * @todo	Handle seekStatus
+	 */
+	public function size () {
+		return $this->getPointerInstance()->size();
+	}
+
+	/**
+	 * Read data a file pointer
+	 *
+	 * @return	mixed	The result of fread()
+	 * @throws	NullPointerException	If the file pointer instance
+	 *									is not set by setPointer()
+	 * @throws	InvalidResourceException	If there is being set
+	 */
+	public function readFromFile () {
+		return $this->getPointerInstance()->readFromFile();
+	}
+
+	/**
+	 * Reads given amount of bytes from file.
+	 *
+	 * @param	$bytes	Amount of bytes to read
+	 * @return	$data	Data read from file
+	 */
+	public function read ($bytes) {
+		return $this->getPointerInstance()->read($bytes);
+	}
+
+	/**
+	 * Write data to a file pointer
+	 *
+	 * @param	$dataStream		The data stream we shall write to the file
+	 * @return	mixed			Number of writes bytes or FALSE on error
+	 * @throws	NullPointerException	If the file pointer instance
+	 *									is not set by setPointer()
+	 * @throws	InvalidResourceException	If there is being set
+	 *											an invalid file resource
+	 */
+	public function writeToFile ($dataStream) {
+		return $this->getPointerInstance()->writeToFile($dataStream);
+	}
+
+	/**
+	 * Rewinds to the beginning of the file
+	 *
+	 * @return	$status 	Status of this operation
+	 */
+	public function rewind () {
+		return $this->getPointerInstance()->rewind();
 	}
 }
 
diff --git a/inc/classes/main/file_directories/stack/class_StackFile.php b/inc/classes/main/file_directories/stack/class_StackFile.php
index 138be491..4cd1f386 100644
--- a/inc/classes/main/file_directories/stack/class_StackFile.php
+++ b/inc/classes/main/file_directories/stack/class_StackFile.php
@@ -48,84 +48,6 @@ class StackFile extends BaseFile implements InputOutputPointer {
 		// Return the prepared instance
 		return $fileInstance;
 	}
-
-	/**
-	 * Determines seek position
-	 *
-	 * @return	$seekPosition	Current seek position
-	 * @todo	0% done
-	 */
-	public final function determineSeekPosition () {
-		$this->partialStub('Unfinished method.');
-	}
-
-	/**
-	 * Seek to given offset (default) or other possibilities as fseek() gives.
-	 *
-	 * @param	$offset		Offset to seek to (or used as "base" for other seeks)
-	 * @param	$whence		Added to offset (default: only use offset to seek to)
-	 * @return	$status		Status of file seek: 0 = success, -1 = failed
-	 * @todo	0% done
-	 */
-	public function seek ($offset, $whence = SEEK_SET) {
-		$this->partialStub('Unfinished method.');
-	}
-
-	/**
-	 * Size of this file
-	 *
-	 * @return	$size	Size (in bytes) of file
-	 * @todo	Handle seekStatus
-	 * @todo	0% done
-	 */
-	public function size () {
-		$this->partialStub('Unfinished method.');
-	}
-
-	/**
-	 * Read data a file pointer
-	 *
-	 * @return	mixed	The result of fread()
-	 * @throws	NullPointerException	If the file pointer instance
-	 *									is not set by setPointer()
-	 * @throws	InvalidResourceException	If there is being set
-	 */
-	public function readFromFile () {
-		$this->partialStub('Unfinished method.');
-	}
-
-	/**
-	 * Reads given amount of bytes from file.
-	 *
-	 * @param	$bytes	Amount of bytes to read
-	 * @return	$data	Data read from file
-	 */
-	public function read ($bytes) {
-		$this->partialStub('bytes=' . $bytes);
-	}
-
-	/**
-	 * Write data to a file pointer
-	 *
-	 * @param	$dataStream		The data stream we shall write to the file
-	 * @return	mixed			Number of writes bytes or FALSE on error
-	 * @throws	NullPointerException	If the file pointer instance
-	 *									is not set by setPointer()
-	 * @throws	InvalidResourceException	If there is being set
-	 *											an invalid file resource
-	 */
-	public function writeToFile ($dataStream) {
-		$this->partialStub('dataStream=' . $dataStream);
-	}
-
-	/**
-	 * Rewinds to the beginning of the file
-	 *
-	 * @return	$status 	Status of this operation
-	 */
-	public function rewind () {
-		$this->partialStub('Unfinished method.');
-	}
 }
 
 // [EOF]