$currentEntry = $iteratorInstance->current();
// Get filename from iterator which is the class' name (according naming-convention)
- $fileName = $currentEntry->getFileName();
+ $fileName = $currentEntry->getFilename();
// Current entry must be a file, not smaller than 100 bytes and not on ignore list
if ((!$currentEntry->isFile()) || (in_array($fileName, $this->ignoreList)) || ($currentEntry->getSize() < 100)) {
* Getter for the file object
*
* @return $fileObject An instance of a SplFileObject
- * @throws UnsupportedOperationException If this method is called
*/
public final function getFileObject () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ return $this->getPointerInstance()->getFileObject();
}
/**
*
* @return mixed The result of fread()
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setFileObject()
* @throws InvalidResourceException If there is being set
*/
public function readFromFile () {
* @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()
+ * is not set by setFileObject()
* @throws InvalidResourceException If there is being set
* an invalid file resource
*/
* 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 setFileObject()
* @throws LogicException If there is no object being set
*/
public function closeFile () {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: fileInfoInstance[' . gettype($fileInfoInstance) . ']=' . $fileInfoInstance . ',isDot=' . intval($this->getDirectoryIteratorInstance()->isDot()));
// Is it a dot-directory or excluded?
- if (($this->getDirectoryIteratorInstance()->isDot()) || (in_array($fileInfoInstance, $except))) {
+ if (($this->getDirectoryIteratorInstance()->isDot()) && (!in_array($fileInfoInstance, $except))) {
// To next entry
$this->getDirectoryIteratorInstance()->next();
* Read data a file pointer
*
* @return mixed The result of fread()
- * @throws NullPointerException If the file pointer instance is not set by setPointer()
+ * @throws NullPointerException If the file pointer instance is not set by setFileObject()
* @throws LogicException If there is no object being set
*/
public function readFromFile () {
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Import SPL stuff
+use \SplFileInfo;
+
/**
* A class for reading text files
*
* @throws FileReadProtectedException If the file cannot be read from
* @return void
*/
- public static final function createFrameworkTextFileInputPointer ($infoInstance) {
+ public static final function createFrameworkTextFileInputPointer (SplFileInfo $infoInstance) {
+ // Check parameter
if (!FrameworkBootstrap::isReachableFilePath($infoInstance)) {
// File cannot be reached
throw new FileIoException($infoInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
// Try to open a handler
$fileObject = $infoInstance->openFile('r');
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEXT-FILE-INPUT: fileObject[]=' . gettype($fileObject));
+
+ // Is it valid?
if ((is_null($fileObject)) || ($fileObject === false)) {
// Something bad happend
throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
$pointerInstance = new FrameworkTextFileInputPointer();
// Set file pointer and file name
- $pointerInstance->setPointer($fileObject);
+ $pointerInstance->setFileObject($fileObject);
// Return the instance
return $pointerInstance;
*
* @param $bytes Amount of bytes to read or whole line (only text files)
* @return $data Data read from file
- * @throws NullPointerException If the file pointer instance is not set by setPointer()
+ * @throws NullPointerException If the file pointer instance is not set by setFileObject()
* @throws InvalidResourceException If there is no object being set
*/
public function read ($bytes = NULL) {
*
* @return void
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setFileObject()
* @todo Add more checks
*/
private function validateFilePointer () {
*
* @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 NullPointerException If the file pointer instance is not set by setFileObject()
* @throws LogicException If there is no object being set
*/
public function writeToFile ($dataStream) {
*
* @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 NullPointerException If the file pointer instance is not set by setFileObject()
* @throws LogicException If there is no object being set
*/
public function writeToFile ($dataStream) {
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseTextFile;
+// Import SPL stuff
+use \SplFileInfo;
+
/**
* A general text input file class
*
/**
* Initializes this text file for reading
*
- * @param $fileName File's name
+ * @param $infoInstance An instance of a SplFileInfo class
* @return void
*/
- protected function initFile ($fileName) {
+ protected function initFile (SplFileInfo $infoInstance) {
// Get a file i/o pointer instance
- $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_input_class', array($fileName));
+ $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_input_class', array($infoInstance));
// ... and set it here
$this->setPointerInstance($pointerInstance);
use Org\Mxchange\CoreFramework\Filesystem\Text\BaseInputTextFile;
use Org\Mxchange\CoreFramework\Stream\Filesystem\CsvInputStreamer;
+// Import SPL stuff
+use \SplFileInfo;
+
/**
* A CSV file input class for writing CSV files
*
/**
* Creates an instance of this File class and prepares it for usage
*
- * @param $fileName Name of the index file
+ * @param $infoInstance An instance of a SplFileInfo class
* @return $fileInstance An instance of this File class
*/
- public final static function createCsvInputFile ($fileName) {
+ public final static function createCsvInputFile (SplFileInfo $infoInstance) {
// Get a new instance
$fileInstance = new CsvInputFile();
// Init this abstract file
- $fileInstance->initFile($fileName);
+ $fileInstance->initFile($infoInstance);
// Return the prepared instance
return $fileInstance;
use Org\Mxchange\CoreFramework\Index\BaseIndex;
use Org\Mxchange\CoreFramework\Index\Indexable;
use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Stacker\Filesystem\BaseFileStacker;
+use Org\Mxchange\CoreFramework\Stacker\Filesystem\BaseFileStack;
use Org\Mxchange\CoreFramework\Stacker\Index\IndexableStack;
// Import SPL stuff
use Org\Mxchange\CoreFramework\Filesystem\Block\CalculatableBlock;
use Org\Mxchange\CoreFramework\Filesystem\Stack\StackableFile;
use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Stacker\Filesystem\BaseFileStacker;
+use Org\Mxchange\CoreFramework\Stacker\Filesystem\BaseFileStack;
// Import SPL stuff
use \SplFileInfo;
* 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 setFileObject()
* @throws InvalidResourceException If there is being set
*/
function closeFile ();
* @param $bytes Amount of bytes to read or whole line (only text files)
* @return $data Data read from file
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setFileObject()
* @throws InvalidResourceException If there is being set
*/
function read ($bytes = NULL);
* @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()
+ * is not set by setFileObject()
* @throws InvalidResourceException If there is being set
* an invalid file resource
*/
// Set namespace for command
$resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Command');
+ $resolverInstance->setCommandName($commandName);
// Return the prepared instance
return $resolverInstance;