]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/binary/class_BaseBinaryFile.php
Renamed Registry -> GenericRegistry to make it clear that this registry does
[core.git] / framework / main / classes / file_directories / binary / class_BaseBinaryFile.php
index fc4140cdb3796689b172bc2df7c5a3b7fb8b82fc..40a24c552f5970f5773e1cee0bb9cf1761996969 100644 (file)
@@ -1,11 +1,15 @@
 <?php
 // Own namespace
-namespace CoreFramework\Filesystem\File;
+namespace Org\Mxchange\CoreFramework\Filesystem\File;
 
 // Import framework stuff
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Filesystem\Block;
-use CoreFramework\Filesystem\Block\CalculatableBlock;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Filesystem\Block;
+use Org\Mxchange\CoreFramework\Filesystem\Block\CalculatableBlock;
+use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
+
+// Import SPL stuff
+use \SplFileInfo;
 
 /**
  * A general binary file class
@@ -29,7 +33,7 @@ use CoreFramework\Filesystem\Block\CalculatableBlock;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class BaseBinaryFile extends BaseAbstractFile {
+abstract class BaseBinaryFile extends BaseAbstractFile {
        /**
         * Separator for header data
         */
@@ -152,7 +156,7 @@ class BaseBinaryFile extends BaseAbstractFile {
                /* Only for debugging
                if (isset($this->gaps[0])) {
                        // Output first and last gap
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] this->gaps[0]=%s,this->gaps[%s]=%s', __METHOD__, __LINE__, print_r($this->gaps[0], TRUE), (count($this->gaps) - 1), print_r($this->gaps[count($this->gaps) - 1], TRUE)));
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] this->gaps[0]=%s,this->gaps[%s]=%s', __METHOD__, __LINE__, print_r($this->gaps[0], true), (count($this->gaps) - 1), print_r($this->gaps[count($this->gaps) - 1], true)));
                } // END - if
                */
 
@@ -318,7 +322,7 @@ class BaseBinaryFile extends BaseAbstractFile {
         */
        public static function isBlockSeparatorFound ($str) {
                // Determine it
-               $isFound = (strpos($str, chr(self::SEPARATOR_ENTRIES)) !== FALSE);
+               $isFound = (strpos($str, chr(self::SEPARATOR_ENTRIES)) !== false);
 
                // Return result
                return $isFound;
@@ -384,12 +388,12 @@ class BaseBinaryFile extends BaseAbstractFile {
        /**
         * Initializes this file class
         *
-        * @param       $fileName       Name of this abstract file
+        * @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('file_raw_input_output_class', array($fileName));
+               $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($infoInstance));
 
                // ... and set it here
                $this->setPointerInstance($pointerInstance);
@@ -403,7 +407,7 @@ class BaseBinaryFile extends BaseAbstractFile {
         * @param       $flushHeader    Whether to flush the header (default: flush)
         * @return      void
         */
-       public function writeData ($seekPosition, $data, $flushHeader = TRUE) {
+       public function writeData ($seekPosition, $data, $flushHeader = true) {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data()=%d - CALLED!', __METHOD__, __LINE__, $seekPosition, strlen($data)));
 
                // Write data at given position
@@ -416,7 +420,7 @@ class BaseBinaryFile extends BaseAbstractFile {
                $this->updateSeekPosition();
 
                // Flush the header?
-               if ($flushHeader === TRUE) {
+               if ($flushHeader === true) {
                        // Flush header
                        $this->flushFileHeader();
 
@@ -453,7 +457,7 @@ class BaseBinaryFile extends BaseAbstractFile {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
 
                // Default is not initialized
-               $isInitialized = FALSE;
+               $isInitialized = false;
 
                // Is the file initialized?
                if ($this->isFileInitialized()) {
@@ -471,7 +475,7 @@ class BaseBinaryFile extends BaseAbstractFile {
                        $this->readFileHeader();
 
                        // The above method does already check the header
-                       $isInitialized = TRUE;
+                       $isInitialized = true;
                } // END - if
 
                // Return result
@@ -487,12 +491,12 @@ class BaseBinaryFile extends BaseAbstractFile {
        public function isFileInitialized () {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
 
-               // Get it from iterator which holds the pointer instance. If FALSE is returned
+               // Get it from iterator which holds the pointer instance. If false is returned
                $fileSize = $this->size();
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] fileSize=%s', __METHOD__, __LINE__, $fileSize));
 
                /*
-                * The returned file size should not be FALSE or NULL as this means
+                * The returned file size should not be false or NULL as this means
                 * that the pointer class does not work correctly.
                 */
                assert(is_int($fileSize));
@@ -754,7 +758,7 @@ class BaseBinaryFile extends BaseAbstractFile {
                $dataArray = explode(chr(self::SEPARATOR_ENTRIES), $data);
 
                // This array must contain two elements
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('dataArray=' . print_r($dataArray, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('dataArray=' . print_r($dataArray, true));
                assert(count($dataArray) == 2);
 
                // Left part is the actual block, right one the back-buffer data
@@ -764,7 +768,7 @@ class BaseBinaryFile extends BaseAbstractFile {
 
        /**
         * Checks wether the current entry is valid (not at the end of the file).
-        * This method will return TRUE if an emptied (nulled) entry has been found.
+        * This method will return true if an emptied (nulled) entry has been found.
         *
         * @return      $isValid        Whether the next entry is valid
         */