*/
public static final function createFrameworkTextFileInputPointer (SplFileInfo $fileInstance) {
// Check parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
// File cannot be reached
throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
$fileObject = $fileInstance->openFile('r');
// Is it valid?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TEXT-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
if (!($fileObject instanceof SplFileObject)) {
// Something bad happend
throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
$pointerInstance->setFileObject($fileObject);
// Return the instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEXT-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
return $pointerInstance;
}
*/
public function readFromFile () {
// Read 1024 Byte data from the file pointer and return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
return $this->read(1024);
}
*/
public function readLine () {
// Read whole line from the file pointer and return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
return $this->read();
}
*/
public function read (int $bytes = 0) {
// Some sanity checks
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
// Cannot be below zero
throw new OutOfBoundsException(sprintf('bytes=%d is not valid', $bytes));
} elseif (is_null($this->getFileObject())) {
// Pointer not initialized
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
} elseif (!is_object($this->getFileObject())) {
// Pointer is not a valid resource!
throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
// Is $bytes set?
if ($bytes > 0) {
// Try to read given characters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: Invoking this->fileObject->fread(%d) ...', $bytes));
$data = $this->getFileObject()->fread($bytes);
} else {
// Try to read whole line
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: Invoking this->fileObject->fgets() ...');
$data = $this->getFileObject()->fgets();
}
// Then return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: data()=%d - EXIT!', strlen($data)));
return $data;
}