*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
+ * @link http://www.ship-simu.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/**
* Protected constructor
+ *
+ * @return void
*/
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
- // Set part description
- $this->setObjectDescription("Handler for reading from files");
-
- // Create unique ID
- $this->generateUniqueId();
-
// Clean-up a little
$this->removeNumberFormaters();
+ $this->removeSystemArray();
}
/**
* Destructor for cleaning purposes, etc
+ *
+ * @return void
*/
public final function __destruct() {
// Is there a resource pointer? Then we have to close the file here!
* Create a file pointer based on the given file. The file will also
* be verified here.
*
- * @param $fileName The file name we shall pass
- * to fopen()
+ * @param $fileName The file name we shall pass to fopen()
* @throws FileIsEmptyException If the provided file name is empty.
- * @throws FilePointerNotOpenedException If fopen() returns not a
- * file resource
+ * @throws FilePointerNotOpenedException If fopen() returns not a
+ * file resource
* @return void
*/
public final static function createFrameworkFileInputPointer ($fileName) {
// Some pre-sanity checks...
- if (is_null($fileName)) {
+ if ((is_null($fileName)) || (empty($fileName))) {
// No filename given
throw new FileIsEmptyException(null, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (!file_exists($fileName)) {
+ // File does not exist!
+ throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_NOT_FOUND);
+ } elseif (!is_readable($fileName)) {
+ // File does not exist!
+ throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ);
}
// Try to open a handler
$filePointer = @fopen($fileName, 'rb');
- if (($filePointer === null) || ($filePointer === false)) {
+ if ((is_null($filePointer)) || ($filePointer === false)) {
// Something bad happend
throw new FilePointerNotOpenedException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
- }
+ } // END - if
// Create new instance
$pointerInstance = new FrameworkFileInputPointer();
*
* @return mixed The result of fread()
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setPointer()
* @throws InvalidFileResourceException If there is being set
* an invalid file resource
*/
*
* @return mixed The result of fread()
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setPointer()
* @throws InvalidFileResourceException If there is being set
* an invalid file resource
*/
*
* @return void
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setPointer()
* @throws InvalidFileResourceException If there is being set
*/
public function closeFile () {
/**
* Setter for the file pointer
*
- * @param $filePointer File resource
+ * @param $filePointer File resource
* @return void
*/
public final function setPointer ($filePointer) {
* Getter for the file pointer
*
* @return $filePointer The file pointer which shall be a valid
- * file resource
+ * file resource
*/
public final function getPointer () {
return $this->filePointer;
/**
* Setter for file name
*
- * @param $fileName The new file name
+ * @param $fileName The new file name
* @return void
*/
public final function setFileName ($fileName) {
/**
* Getter for file name
*
- * @return $fileName The current file name
+ * @return $fileName The current file name
*/
public final function getFileName () {
return $this->fileName;