]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/file_directories/io/class_FrameworkFileInputOutputPointer.php
Add stuff for reading header of a file-based stack.
[core.git] / inc / classes / main / file_directories / io / class_FrameworkFileInputOutputPointer.php
index 198c5b09df6c463f8bcdd9a4ee8f84b1d24f7bad..073c2c7fe0f91059c99001e783742329f0f52ad0 100644 (file)
@@ -75,7 +75,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
        }
 
        /**
-        * Read data a file pointer
+        * Read 1024 bytes data from a file pointer
         *
         * @return      mixed   The result of fread()
         * @throws      NullPointerException    If the file pointer instance
@@ -92,7 +92,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                }
 
                // Read data from the file pointer and return it
-               return fread($this->getPointer(), 1024);
+               return $this->read(1024);
        }
 
        /**
@@ -139,6 +139,23 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                // Move the file pointer
                return fseek($this->getPointer(), $seekPosition, $whence);
        }
+
+       /**
+        * Reads given amount of bytes from file.
+        *
+        * @param       $bytes  Amount of bytes to read
+        * @return      $data   Data read from file
+        */
+       public function read ($bytes) {
+               // Try to read given characters
+               $data = fread($this->getPointer(), $bytes);
+
+               // Was this successfull?
+               assert(is_string($data));
+
+               // Then return it
+               return $data;
+       }
 }
 
 // [EOF]