Zips the root folder and streams the contents of the zip into the given stream

@param resource $streamPointer Pointer to the stream to copy the zip
@return void
513461
public function zipRootFolderAndCopyToStream($streamPointer)
    {
        $zipHelper = new ZipHelper($this->rootFolder);

        // In order to have the file's mime type detected properly, files need to be added
        // to the zip file in a particular order.
        // @see http://www.jejik.com/articles/2010/03/how_to_correctly_create_odf_documents_using_zip/
        $zipHelper->addUncompressedFileToArchive($this->rootFolder, self::MIMETYPE_FILE_NAME);

        $zipHelper->addFolderToArchive($this->rootFolder, ZipHelper::EXISTING_FILES_SKIP);
        $zipHelper->closeArchiveAndCopyToStream($streamPointer);

        // once the zip is copied, remove it
        $this->deleteFile($zipHelper->getZipFilePath());
    }
1041705
public function tell(){
        if(null === $this->resource){
            throw new Exception\StreamUnavailableException(
                static::EXCEPTION_MSG_UNAVAILABLE
            );
        }

        if(false === ($point = ftell($this->resource))){
            throw new \RuntimeException("Failed to get file pointer position.");
        }

        return $point;
    }
1253038
protected function attachResource($stream) : void
    {
        if (is_resource($stream) === false) {
            throw new \InvalidArgumentException("Argument must be a valid resource type.");
        }

        $this->stream = $stream;
        $stats = fstat($this->stream);


        // Identifica se o "Stream" é "pipe"
        $bitMask = 0010000;
        $this->isPipe = (($stats["mode"] & $bitMask) !== 0);

        // Identifica o tamanho do "Stream" (se possível).
        $this->size = ((isset($stats["size"]) && $this->isPipe === false) ? $stats["size"] : null);

        // Resgata os metadados do "Stream"
        $this->metaData = stream_get_meta_data($this->stream);

        // Verifica se o "Stream" é "pesquisável"
        $this->seekable = ($this->isPipe === false && $this->metaData["seekable"]);



        $streamModes = [
            "readable" => ["r", "r+", "w+", "a+", "x+", "c+"],
            "writable" => ["r+", "w", "w+", "a", "a+", "x", "x+", "c", "c+"]
        ];

        // Verifica se é possível alterar o "Stream"
        foreach ($streamModes["writable"] as $mode) {
            if (strpos($this->metaData["mode"], $mode) === 0) {
                $this->writable = true;
                break;
            }
        }

        
        // Verifica se é possível ler o "Stream"
        foreach ($streamModes["readable"] as $mode) {
            if (strpos($this->metaData["mode"], $mode) === 0) {
                $this->readable = true;
                break;
            }
        }
    }
1273841
private function fillZipWithFileContents($zipFileUrl)
    {
        $this->zip->open($zipFileUrl, \ZipArchive::CREATE);
        $this->finalizeSheet();
        $this->finalizeStyles();
        $this->finalizeDefaultXmls();
    }
440738
private static function writeStream(StreamInterface $stream, $path)
    {
        $dir = dirname($path);

        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }

        $handle = fopen($path, 'wb+');

        if (false === $handle) {
            throw new RuntimeException('Unable to write to designated path');
        }

        $stream->rewind();

        while (!$stream->eof()) {
            fwrite($handle, $stream->read(4096));
        }

        fclose($handle);
    }
1144588
private function decorateStream($encoding, StreamInterface $stream)
    {
        if ('chunked' == strtolower($encoding)) {
            return new DechunkStream($stream);
        }

        if ('compress' == strtolower($encoding)) {
            return new DecompressStream($stream);
        }

        if ('deflate' == strtolower($encoding)) {
            return new InflateStream($stream);
        }

        if ('gzip' == strtolower($encoding)) {
            return new GzipDecodeStream($stream);
        }

        return false;
    }
717210
function _createStreamPointer(self, stream, serializer) {
  let id = uuid();
  let readable = typeof stream.read === 'function';
  let type = readable ? 'readable' : 'writable';
  let pointer = `boscar:${type}:${id}`;

  self.streams.set(id, stream);

  if (readable) {
    _bindReadable(pointer, stream, serializer);
  }

  return pointer;
}
1106724
public static function zipDir($sourcePath, $outZipPath, $del = false, $delDir = false)
  {
    $pathInfo = pathInfo($sourcePath);
    $parentPath = $pathInfo['dirname'];
    $dirName = $pathInfo['basename'];

    $z = new \ZipArchive();
    $z->open($outZipPath, \ZipArchive::CREATE);
    $z->addEmptyDir($dirName);
    self::folderToZip($sourcePath, $z, strlen("$parentPath/"), $del);
    if(true===$delDir)rmdir($sourcePath);
    $z->close();
  }
444829
private function setFilesystemRootDir($rootDir, ContainerBuilder $container)
    {
        $definition = $container->getDefinition($this->getAlias() . '.filesystem');

        $definition->replaceArgument(0, $rootDir);
    }
730381
public function setTemplateSource($newSource, $fromPointer = false)
    {
        if ($fromPointer === true) {
            $this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource;
        } else {
            $this->templateSource = $newSource;
        }
    }
521364
public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $typePointer): void
    {
        $tokens = $phpcsFile->getTokens();

        /** @var int $namePointer */
        $namePointer = TokenHelper::findNext($phpcsFile, T_STRING, $typePointer + 1);
        $namespacePointer = TokenHelper::findPrevious($phpcsFile, T_NAMESPACE, $typePointer - 1);

        if (!$this->hasNamespace($namespacePointer)) {
            return;
        }

        $typeName = NamespaceHelper::normalizeToCanonicalName(
            ClassHelper::getFullyQualifiedName($phpcsFile, $typePointer)
        );

        $rootDirectory = \getcwd() . \DIRECTORY_SEPARATOR;
        $fileInfo = new \SplFileInfo($phpcsFile->getFilename());

        foreach ($this->rootNamespaces as $directory => $namespace) {
            if ($this->shouldSkip($directory)) {
                return;
            }

            if (StringHelper::startsWith($typeName, $namespace)) {
                $expectedTypeName = rtrim($fileInfo->getPathname(), '.' . $fileInfo->getExtension());
                $expectedTypeName = \str_replace($rootDirectory . $directory, '', $expectedTypeName);
                $expectedTypeName = \str_replace(\DIRECTORY_SEPARATOR, '\\', $expectedTypeName);
                $expectedTypeName = $namespace . '\\' . ltrim($expectedTypeName, '\\');

                if (strcasecmp($typeName, $expectedTypeName) === 0) {
                    return;
                }
            }
        }

        $phpcsFile->addError(
            sprintf(
                '%s name %s does not match filepath %s.',
                ucfirst($tokens[$typePointer]['content']),
                $typeName,
                $phpcsFile->getFilename()
            ),
            $namePointer,
            self::CODE_NO_MATCH_BETWEEN_TYPE_NAME_AND_FILE_NAME
        );
    }
350776
public function init()
    {
        $stream = @fopen($this->config['url'], 'a');
        if (!$stream) {
            throw new \RuntimeException(sprintf("Couldn't open resource '%s'", $this->config['url']));
        }

        $this->stream = $stream;

        if (!empty($this->config['lock']) && $this->config['lock'] === true && stream_supports_lock($this->stream)) {
            $this->useLocks = true;
        }
    }
430643
protected function runSniffer(File $phpCsFile, int $stackPointer): void
    {
        if (!$this->hasMethodAnnotation($phpCsFile, $stackPointer)
            && $this->fileExists($phpCsFile, $this->getMethodAnnotationFileName($phpCsFile))
        ) {
            $fix = $phpCsFile->addFixableError($this->getMethodName() . '() annotation missing', $stackPointer, 'Missing');

            if ($fix) {
                $this->addMethodAnnotation($phpCsFile, $stackPointer);
            }
        }
    }
475083
public static function parse(StreamReader $streamReader)
    {
        $pos = $startPos = $streamReader->getOffset();
        $openBrackets = 1;
        do {
            $buffer = $streamReader->getBuffer(false);
            for ($length = \strlen($buffer); $openBrackets !== 0 && $pos < $length; $pos++) {
                switch ($buffer[$pos]) {
                    case '(':
                        $openBrackets++;
                        break;
                    case ')':
                        $openBrackets--;
                        break;
                    case '\\':
                        $pos++;
                }
            }
        } while ($openBrackets !== 0 && $streamReader->increaseLength());

        $result = \substr($buffer, $startPos, $openBrackets + $pos - $startPos - 1);
        $streamReader->setOffset($pos);

        $v = new self;
        $v->value = $result;

        return $v;
    }
995398
public function writeCompressedFile($compressedFilepath, $filepath)
	{
		$filePointer = fopen($compressedFilepath, 'w');
		fwrite($filePointer, gzencode(file_get_contents($filepath), 9));
		fclose($filePointer);
	}
1304024
private function copyStreamToStream($source, $target) : void
    {
        if (@stream_copy_to_stream($source, $target) === false) {
            throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']);
        }
    }
1138996
public function getStreamContentStartOffset()
    {
        if ($this->parent) {
            return $this->streamContentStartPos - $this->parent->streamPartStartPos;
        }
        return $this->streamContentStartPos;
    }