]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/file_directories/input/class_FrameworkFileInputPointer.php
Added read().
[core.git] / inc / classes / main / file_directories / input / class_FrameworkFileInputPointer.php
index f70ef5a12b90596adb19bef552f6e50326c1ff95..94bb8dccb3ed8a3b9ae5981a0923f9b251d6b2a6 100644 (file)
@@ -21,7 +21,7 @@
  * 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 FrameworkFileInputPointer extends BaseFileIo {
+class FrameworkFileInputPointer extends BaseFileIo implements InputPointer {
        /**
         * Protected constructor
         *
@@ -36,9 +36,9 @@ class FrameworkFileInputPointer extends BaseFileIo {
         * 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      FileIoException         If fopen() returns not a file resource
+        * @throws      FileIoException                 If fopen() returns not a file resource
         * @return      void
         */
        public static final function createFrameworkFileInputPointer ($fileName) {
@@ -90,7 +90,24 @@ class FrameworkFileInputPointer extends BaseFileIo {
                }
 
                // Read data from the file pointer and return it
-               return fread($this->getPointer(), 1024);
+               return $this->read(1024);
+       }
+
+       /**
+        * 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;
        }
 }