}
// 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;
}
}