appendStream.

@param string $output
@param string|resource $input
@param int $offset
775541
public function appendStream($output, $input, $offset = 0)
    {
        $mode = ($offset === 0) ? 'wb' : 'ab';
        $output = $this->convertToResource($output, $mode, 'output');
        $input = $this->convertToResource($input, 'rb', 'input');

        fseek($output, $offset);
        while ($buffer = fread($input, 4096)) {
            fwrite($output, $buffer);
        }

        fclose($output);
        fclose($input);
    }
506285
public void write(String text, int offset, int length) {
        buffer.append(text, offset, offset + length);
    }
534343
public void write(byte []buffer, int offset, int length)
    throws IOException
  {
    _file.write(buffer, offset, length);
  }
441030
@Override
  public void write(byte []buffer, int offset, int length)
    throws IOException
  {
    _stream.write(buffer, offset, length, false);
  }
747939
public static function build($input, $output)
    {
        /**
         * The directory that contains the input file.
         *
         * Used to include common files.
         *
         * @var string
         */
        $directory = dirname($input) . '/';

        /**
         * The name of the file that contains the context.
         *
         * @var string
         */
        $file = basename($input);

        /**
         * The name of the context.
         *
         * @var string
         */
        $name = substr($file, 0, -4);

        /**
         * The name of the class that defines this context.
         *
         * @var string
         */
        $class = 'Context' . $name;

        /**
         * The formatted name of this context.
         *
         * @var string
         */
        $formattedName = static::formatName($name);

        file_put_contents(
            $output . '/' . $class . '.php',
            static::generate(
                [
                    'name' => $formattedName,
                    'class' => $class,
                    'link' => static::$LINKS[$name],
                    'keywords' => static::readWords(
                        [
                            $directory . '_common.txt',
                            $directory . '_functions' . $file,
                            $directory . $file,
                        ]
                    ),
                ]
            )
        );
    }
400151
public function write($output)
    {
        //lets parse the file
        if ($this->_hasBeenModified($this->_file) || !file_exists($output)) {
            //get the data
            file_put_contents($output, $this->getData());
            //update the timestamp
            $this->_cache_data['timestamp'] = time();
            file_put_contents($this->_cache_file, serialize($this->_cache_data));
        }
    }
681855
protected function _populateOutput(array &$output, $key, $value) {
        if (strpos($key, '.') === false) {
            $output[$key] = $value;
            return;
        }
        $array = Garp_Util_String::toArray($key, '.', $value);
        $output += $array;
    }
321466
public function setStdoutFile(string $path, bool $append = false): Process
    {
        $this->setOutputFile(self::STDOUT, $path, $append);
        return $this;
    }
982343
protected InputStream getInputStream(final File f, final long offset)
    throws IOException {
        FileInputStream fin = new FileInputStream(f); 
        return new BufferedInputStream(fin);
    }
1160676
function _append($data)
    {
        if ($this->_using_tmpfile) {
            // Add CONTINUE records if necessary
            if (strlen($data) > $this->_limit) {
                $data = $this->_addContinue($data);
            }
            fwrite($this->_filehandle, $data);
            $this->_datasize += strlen($data);
        } else {
            parent::_append($data);
        }
    }
480715
public static void append(Appendable out, Object object) throws IOException {
        if (object instanceof String) {
            out.append((String) object);
        } else if (object instanceof Object[]) {
            out.append(toArrayString((Object[]) object));
        } else if (object instanceof Map) {
            out.append(toMapString((Map) object));
        } else if (object instanceof Collection) {
            out.append(toListString((Collection) object));
        } else if (object instanceof Writable) {
            Writable writable = (Writable) object;
            Writer stringWriter = new StringBuilderWriter();
            writable.writeTo(stringWriter);
            out.append(stringWriter.toString());
        } else if (object instanceof InputStream || object instanceof Reader) {
            // Copy stream to stream
            Reader reader;
            if (object instanceof InputStream) {
                reader = new InputStreamReader((InputStream) object);
            } else {
                reader = (Reader) object;
            }
            char[] chars = new char[8192];
            int i;
            while ((i = reader.read(chars)) != -1) {
                for (int j = 0; j < i; j++) {
                    out.append(chars[j]);
                }
            }
            reader.close();
        } else {
            out.append(toString(object));
        }
    }
260941
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);

        $batchSize = NumberUtils::bound($input->getOption('batch-size'), 1, 1000);
        $batchDelay = NumberUtils::bound($input->getOption('batch-delay'), 100, 600000);
        $since = $input->getOption('since');
        $until = $input->getOption('until');
        $context = json_decode($input->getOption('context') ?: '{}', true);
        $context['tenant_id'] = (string)$input->getOption('tenant-id');
        $streamId = $input->getArgument('stream-id') ? StreamId::fromString($input->getArgument('stream-id')) : null;

        if (!empty($since)) {
            $since = Microtime::fromString(str_pad($since, 16, '0'));
        }

        if (!empty($until)) {
            $until = Microtime::fromString(str_pad($until, 16, '0'));
        }

        $i = 0;
        $receiver = function (Event $event, StreamId $streamId) use ($errOutput, $batchSize, $batchDelay, &$i) {
            ++$i;

            try {
                echo json_encode($event) . PHP_EOL;
            } catch (\Throwable $e) {
                $errOutput->writeln($e->getMessage());
            }

            if (0 === $i % $batchSize) {
                if ($batchDelay > 0) {
                    usleep($batchDelay * 1000);
                }
            }
        };

        if ($streamId) {
            $this->getPbjx()->getEventStore()->pipeEvents($streamId, $receiver, $since, $until, $context);
        } else {
            $this->getPbjx()->getEventStore()->pipeAllEvents($receiver, $since, $until, $context);
        }
    }
694970
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $files = $input->getArgument('files');
        $fileSuffix = ' -f ' . implode(' -f ', $files);

        $command = sprintf('%s stop -d', $fileSuffix);
        $response = $this->getFacade()->runDockerCompose($command);

        if ($output->isVerbose()) {
            $output->writeln($response);
        }
    }
755011
public void append(char[] ch, int offset, int length) {
        if (this.length + length > this.ch.length) {
            char[] newch = new char[this.ch.length + length + DEFAULT_SIZE];
            System.arraycopy(this.ch, 0, newch, 0, this.length);
            this.ch = newch;
        }
        System.arraycopy(ch, offset, this.ch, this.length, length);
        this.length += length;
    }
95640
public function hook(OutputInterface $output, array $response)
    {
        $this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
    }
969367
public function FromBytes($stream, $offset) // ret <= 0 - error
	{
		$moved = 0;
		$vi = 0;
		$moved += $parsed = ProtoBuf_Bytes2Varint($stream, $offset + $moved, $vi);
		if ($parsed <= 0)
			return $parsed;

		//echo "vi $vi\n";
		$this->wt = ($vi & 0x07);
		$this->fn = ($vi >> 3);
		//echo "field wt " . $this->wt . " fn " . $this->fn . "\n";

		switch ($this->wt)
		{
			case ProtoBuf_Field::ProtoBuf_WireType_Varint: // TODO: in case we need this information, create get function
				$this->data = 0;
				$moved += $parsed = ProtoBuf_Bytes2Varint($stream, $offset + $moved, $this->data);
				break;
			case ProtoBuf_Field::ProtoBuf_WireType_64bit:
				$this->data = substr($stream, $offset + $moved, 8);
				$high4 = ProtoBuf_Bytes2Fixed(substr($this->data, 4), 4);
				if ($high4 == 0)
				{
					$this->fixed64_is_32bit = true;
					$this->data = ProtoBuf_Bytes2Fixed($this->data, 4);
				}
				else
				{
					$this->fixed64_is_32bit = false;
					$this->data = ProtoBuf_Bytes2Fixed($this->data, 8);
				}
				$moved += 8;
				break;
			case ProtoBuf_Field::ProtoBuf_WireType_LengthDelimited:
				$moved += $parsed = ProtoBuf_Bytes2Varint($stream, $offset + $moved, $vi);
				if ($parsed <= 0)
					return $parsed;
				$this->data = substr($stream, $offset + $moved, $vi);
				$moved += $vi;
				break;
			/*case ProtoBuf_Field::ProtoBuf_WireType_StartGroup: // TODO: in case we need this information, create get function
				break;
			case ProtoBuf_Field::ProtoBuf_WireType_EndGroup: // TODO: in case we need this information, create get function
				break;*/
			case ProtoBuf_Field::ProtoBuf_WireType_32bit:
				$this->data = substr($stream, $offset + $moved, 4);
				$this->data = ProtoBuf_Bytes2Fixed($this->data, 4);
				$moved += 4;
				break;
			default:
				die("[lib_protobuf.inc] Unrecognized protobuf wire type '" . $this->wt . "'\n");
				break;
		}

		return $moved;
	}
375130
public function setOutputStreams( $stdout = STDOUT, $stderr = STDERR )
    {
        $this->stdout = $stdout;
        $this->stderr = $stderr;
    }