コード例 #1
0
ファイル: Stream.class.php プロジェクト: Sect0R/WOOPS
 /**
  * Class constructor
  * 
  * @param   string  The binary data for which to create a stream
  * @return  void
  * @see     Woops_Binary_Stream::__construct
  */
 public function __construct($data = '')
 {
     // Calls the parent constructor
     parent::__construct($data);
     // Checks if we have compressed data
     if ($data && substr($this->_data, 0, 3) === 'CWS') {
         // Sets the compressed flag
         $this->_isCompressed = true;
     }
 }
コード例 #2
0
ファイル: Stream.class.php プロジェクト: Sect0R/WOOPS
 /**
  * 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_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_Binary_File_Resource_Stream_Exception('Passed argument must be a valid file handle', Woops_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);
 }