Пример #1
0
 /**
  * @inheritdoc
  */
 protected function doAdd(ResourceInterface $resource, $files, $recursive)
 {
     $files = (array) $files;
     if (empty($files)) {
         $resource->getResource()->close();
         throw new InvalidArgumentException("no files provided");
     }
     $this->addEntries($resource, $files, $recursive);
     return $files;
 }
Пример #2
0
 /**
  * @param string $to
  */
 protected function doTarExtractMembers($options, ResourceInterface $resource, $members, $to = null, $overwrite = false)
 {
     if (null !== $to && !is_dir($to)) {
         throw new InvalidArgumentException(sprintf("%s is not a directory", $to));
     }
     $members = (array) $members;
     $builder = $this->inflator->create();
     if ($overwrite == false) {
         $builder->add('-k');
     }
     $builder->add('--extract')->add(sprintf('--file=%s', $resource->getResource()));
     foreach ($this->getExtractMembersOptions() as $option) {
         $builder->add($option);
     }
     foreach ((array) $options as $option) {
         $builder->add((string) $option);
     }
     if (null !== $to) {
         $builder->add('--directory')->add($to);
     }
     if (!$this->addBuilderFileArgument($members, $builder)) {
         throw new InvalidArgumentException('Invalid files');
     }
     $process = $builder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         throw new RuntimeException(sprintf('Unable to execute the following command %s {output: %s}', $process->getCommandLine(), $process->getErrorOutput()));
     }
     return $members;
 }
Пример #3
0
 /**
  * @inheritdoc
  */
 protected function doExtractMembers(ResourceInterface $resource, $members, $to)
 {
     if (null !== $to && !is_dir($to)) {
         throw new InvalidArgumentException(sprintf("%s is not a directory", $to));
     }
     $members = (array) $members;
     $builder = $this->deflator->create();
     $builder->add($resource->getResource());
     if (null !== $to) {
         $builder->add('-d')->add($to);
     }
     if (!$this->addBuilderFileArgument($members, $builder)) {
         throw new InvalidArgumentException('Invalid files');
     }
     $process = $builder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         throw new RuntimeException(sprintf('Unable to execute the following command %s {output: %s}', $process->getCommandLine(), $process->getErrorOutput()));
     }
     return $members;
 }