コード例 #1
0
 /**
  * Constructor
  *
  * @param   io.streams.InputStream in
  */
 public function __construct(InputStream $in)
 {
     // Read GZIP format header
     // * ID1, ID2 (Identification, \x1F, \x8B)
     // * CM       (Compression Method, 8 = deflate)
     // * FLG      (Flags)
     // * MTIME    (Modification time, Un*x timestamp)
     // * XFL      (Extra flags)
     // * OS       (Operating system)
     $header = unpack('a2id/Cmethod/Cflags/Vtime/Cextra/Cos', $in->read(10));
     if ("‹" != $header['id']) {
         throw new IOException('Invalid format, expected \\037\\213, have ' . addcslashes($header['id'], "..ÿ"));
     }
     if (8 != $header['method']) {
         throw new IOException('Unknown compression method #' . $header['method']);
     }
     // Now, convert stream to file handle and append inflating filter
     $wri = 'zlib.bounded://' . $in->hashCode();
     self::$wrapped[$wri] = $in;
     $this->in = fopen($wri, 'r');
     if (!stream_filter_append($this->in, 'zlib.inflate', STREAM_FILTER_READ)) {
         throw new IOException('Could not append stream filter');
     }
 }
コード例 #2
0
 /**
  * Open an input stream for reading and return URI
  *
  * @param   io.streams.InputStream s
  * @return  string
  */
 public static function readableUri(InputStream $s)
 {
     self::$streams[$s->hashCode()] = $s;
     return 'iostrr://' . $s->hashCode();
 }