*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/**
* Close a file source and set it's instance to null and the file name
- * to empty
+ * to empty.
*
* @return void
- * @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * @throws NullPointerException If the file pointer instance is not set by setPointer()
* @throws InvalidResourceException If there is being set
*/
- public function closeFile () {
+ private function closeFile () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName()));
+
if (is_null($this->getPointer())) {
// Pointer not initialized
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
}
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Closing file %s ...', __METHOD__, __LINE__, $this->getFileName()));
+
// Close the file pointer and reset the instance variable
@fclose($this->getPointer());
$this->setPointer(NULL);
$this->setFileName('');
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__));
}
/**
/**
* Getter for the file pointer
*
- * @return $filePointer The file pointer which shall be a valid
- * file resource
+ * @return $filePointer The file pointer which shall be a valid file resource
*/
public final function getPointer () {
return $this->filePointer;
return ftell($this->getPointer());
}
+ /**
+ * Determines whether the EOF has been reached
+ *
+ * @return $isEndOfFileReached Whether the EOF has been reached
+ */
+ public final function isEndOfFileReached () {
+ return feof($this->getPointer());
+ }
+
/**
* Seek to given offset (default) or other possibilities as fseek() gives.
*