* 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
*
* 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) {
}
// 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;
}
}