Example #1
0
 /**
  * Class constructor
  * 
  * @param   resource    The file handle for which to create a binary stream
  * @param   boolean     Whether to close the file handle or not
  * @return  void
  * @see     Woops_Zip_Binary_Stream::__construct
  */
 public function __construct($handle, $closeHandle = true)
 {
     // Checks if the file exists
     if (!is_resource($handle)) {
         // Error - The file does not exist
         throw new Woops_Zip_Binary_File_Resource_Stream_Exception('Passed argument must be a valid file handle', Woops_Zip_Binary_File_Resource_Stream_Exception::EXCEPTION_NO_RESOURCE);
     }
     // Storage
     $data = '';
     // Reads until the end of the file handle
     while (!feof($handle)) {
         // Reads from the file handle
         $data .= fread($handle, 8192);
     }
     // Checks if we must close the file handle
     if ($closeHandle) {
         // Closes the file handle
         fclose($handle);
     }
     // Calls the parent constructor
     parent::__construct($data);
 }