Beispiel #1
0
 public function testWriteAutoCloseOn()
 {
     $value = get_test_string();
     $value_size = strlen($value);
     $value_stream = string_to_stream($value);
     $stream = string_to_stream("");
     $buffer_size = 1000;
     $writer = new StreamWriter($value_stream, $stream, $buffer_size);
     $this->assertSame("stream", get_resource_type($stream));
     while ($ret = $writer->write(true)) {
     }
     // This works everywhere except Travis-CI, no idea why
     // $this->assertSame("Unknown", get_resource_type($stream));
 }
 /**
  * Constructor
  *
  * @param   io.Stream stream
  * @param   int foreground default 0
  */
 public function __construct($stream, $foreground = 0)
 {
     parent::__construct($stream);
     $this->foreground = $foreground;
 }
 /**
  * Constructor
  *
  * @see     php://imagetruecolortopalette
  * @param   io.Stream stream
  * @param   bool dither default FALSE indicates if the image should be dithered
  * @param   int ncolors default 256 maximum # of colors retained in the palette
  */
 public function __construct($stream, $dither = FALSE, $ncolors = 256)
 {
     parent::__construct($stream);
     $this->dither = $dither;
     $this->ncolors = $ncolors;
 }
 static function __static()
 {
     self::$GD_USERSTREAMS_BUG = version_compare(PHP_VERSION, '5.5.0RC1', '>=') && version_compare(PHP_VERSION, '5.5.1', '<') && 0 !== strncmp('WIN', PHP_OS, 3);
 }
 /**
  * Constructor
  *
  * @param   io.Stream stream
  * @param   int format default IMG_GD2_RAW one of the IMG_GD2_* constants
  */
 public function __construct($stream, $format = IMG_GD2_RAW)
 {
     parent::__construct($stream);
     $this->format = $format;
 }
 /**
  * Constructor
  *
  * @param   io.Stream stream
  * @param   int quality default 75
  */
 public function __construct($stream, $quality = 75)
 {
     parent::__construct($stream);
     $this->quality = $quality;
 }
Beispiel #7
0
 /**
  * Serialize a single file.
  *
  * @param FileEntry $file The file to serialize.
  *
  * @return StreamWriter
  */
 private function serializeFile(FileEntry $file)
 {
     $result = new StreamWriter('php://temp');
     $fileName = $file->getFilename();
     $metaData = $file->getMetadata();
     if (!empty($metaData)) {
         $metaData = serialize($metaData);
     }
     $result->writeUint32le(strlen($fileName))->write($fileName)->writeUint32le($file->getSizeUncompressed())->writeUint32le($file->getTime()->getTimestamp())->writeUint32le($file->getSizeCompressed())->writeUint32le($file->getCrc())->writeUint32le($file->getFlags())->writeUint32le(strlen($metaData))->write($metaData)->seek(0);
     $this->bins->write($file->getCompressedContent());
     return $result;
 }