Renders a single file and applies filters on it

@param string $tool conversion tool to use
@param string $source rST source file
@param string $targetFile target file name

@return void
345399
protected function render($tool, $source, $targetFile)
    {
        if (count($this->filterChains) == 0) {
            $this->renderFile($tool, $source, $targetFile);
            return;
        }

        $tmpTarget = tempnam(sys_get_temp_dir(), 'rST-');
        $this->renderFile($tool, $source, $tmpTarget);

        $this->fileUtils->copyFile(
            new PhingFile($tmpTarget),
            new PhingFile($targetFile),
            $this->getProject(),
            true,
            false,
            $this->filterChains,
            $this->mode
        );
        unlink($tmpTarget);
    }
1219532
public function applyAction(&$source, &$target, $handler, &$action)
    {
        $result = null;
        $this->hook->attach('image.style.apply.before', $source, $target, $handler, $action, $result);

        if (isset($result)) {
            return $result;
        }

        try {
            $callback = Handler::get($handler, null, 'process');
            $result = call_user_func_array($callback, array(&$source, &$target, &$action));
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

        $this->hook->attach('image.style.apply.after', $source, $target, $handler, $action, $result);
        return $result;
    }
291246
public static function render($source, $rules = array(), $directory = null) {
        if (!$directory)
            $directory = getcwd();
        
        return self::fromSpecification(
            fphp\Specification\TemplateSpecification::fromArrayAndSettings(
                array(
                    "source" => $source,
                    "rules" => $rules
                ), fphp\Settings::inDirectory($directory))
        )->getContent()->getSummary();
    }
438702
public function load($sourcePath, $targetPath)
  {
    $mapper = new AssetMapper();
    $mapper->map($sourcePath, $targetPath);

    return $mapper;
  }
1175401
public function copy($target, $source)
    {
        if (!$this->exists($target)) {
            throw new \RuntimeException("$target does not exist.", E_ERROR);
        }

        if (!$this->exists($source)) {
            $this->makeDirectory(dirname($source), true);
        }

        return file_put_contents($source, $this->get($target));
    }
463590
public function renderTwigFile($template, $target, array $parameters, $sourceDir)
    {
        if (!is_dir(dirname($target))) {
            mkdir(dirname($target), 0777, true);
        }

        return file_put_contents($target, $this->renderTwig($template, $parameters, $sourceDir));
    }
281604
public function serialize($targetFile,$data)
    {
        $contents = serialize($data);
        $this->putFileContents($targetFile,$contents);
    }
736219
public static void copy(final File sourceFile, File targetFile, final boolean overwrite) throws IOException {
        if (sourceFile == null) {
            throw new IOException("Source must not be null");
        }

        if (targetFile == null) {
            throw new IOException("Target must not be null");
        }

        // checks
        if ((false == sourceFile.isFile()) || (false == sourceFile.exists())) {
            throw new IOException("Source file '" + sourceFile.getAbsolutePath() + "' not found!");
        }

        if (true == targetFile.exists()) {
            if (true == targetFile.isDirectory()) {

                // Directory? -> use source file name
                targetFile = new File(targetFile, sourceFile.getName());
            } else if (true == targetFile.isFile()) {
                if (false == overwrite) {
                    throw new IOException("Target file '" + targetFile.getAbsolutePath() + "' already exists!");
                }
            } else {
                throw new IOException("Invalid target object '" + targetFile.getAbsolutePath() + "'!");
            }
        } else {
            // create parent dir
            FileUtils.forceMkdir(targetFile.getParentFile());
        }

        FileInputStream input = null;
        FileOutputStream output = null;

        try {
            input = new FileInputStream(sourceFile);
            output = new FileOutputStream(targetFile);
            copy(input, output);
            output.flush();
        } finally {
            IOUtils.closeQuietly(input);
            IOUtils.closeQuietly(output);
        }
    }
958923
private function deep_copy($source, $target_path)
    {
        // Loop through $source dir.
        $contents = \scandir($source);

        if (empty($contents)) {
            return;
        }

        foreach ($contents as $file) {
            if ('.' === $file || '..' === $file) {
                continue;
            }

            $src_path = \trailingslashit($source) . $file;
            $new_path = \trailingslashit($target_path) . $file;

            if (\is_dir($src_path)) {
                $this->mkdir($new_path);
                $this->deep_copy($src_path, $new_path);
                continue;
            }

            if ($this->file->copy($src_path, $new_path, $this->force)) {
                $this->copied[] = $new_path;
            }
        }
    }
136309
public function render($context, $targetDir)
    {
        $types = array_merge($context->classes, $context->interfaces, $context->traits);
        foreach($types as $name => $type) {
            $types[$name] = (array) $type;
            if ($type instanceof ClassDoc) {
                $types[$name]['type'] = 'class';
            } elseif ($type instanceof InterfaceDoc) {
                $types[$name]['type'] = 'interface';
            } elseif ($type instanceof TraitDoc) {
                $types[$name]['type'] = 'trait';
            }
        }
        file_put_contents($targetDir . '/types.json', json_encode($types, JSON_PRETTY_PRINT));
    }
81382
public static function directoryDiff($source, $target)
    {
        $sourceFiles = self::globr($source, '*');
        $targetFiles = self::globr($target, '*');

        $sourceFiles = array_map(function ($file) use ($source) {
            return str_replace($source, '', $file);
        }, $sourceFiles);

        $targetFiles = array_map(function ($file) use ($target) {
            return str_replace($target, '', $file);
        }, $targetFiles);

        $diff = array_diff($targetFiles, $sourceFiles);

        return array_values($diff);
    }
1337940
protected function _copy($source, $targetDir, $name) {
		$res = false;
		
		if ($this->tmp) {
			$local  = $this->getTempFile();
			$target = $targetDir.DIRECTORY_SEPARATOR.$name;

			if (ftp_get($this->connect, $local, $source, FTP_BINARY)
			&& ftp_put($this->connect, $target, $local, $this->ftpMode($target))) {
				$res = $target;
			}
			@unlink($local);
		}
		
		return $res;
	}
942696
public static function unlinkTargetFilesNotPresentInSource($source, $target)
    {
        $diff = self::directoryDiff($source, $target);
        $diff = self::sortFilesDescByPathLength($diff);

        foreach ($diff as $file) {
            $remove = $target . $file;

            if (is_dir($remove)) {
                @rmdir($remove);
            } else {
                self::deleteFileIfExists($remove);
            }
        }
    }
1369864
public function copyFiles($source, $target, $files)
    {
        foreach ($files as $file) {
            $this->copyFile($source, $target, $file);
        }
    }
1055351
public function removeEdge( $source, $target )
	{
		if( $source->getNodeName() < $target->getNodeName() )
			$this->edgeSet->removeEdge( $source, $target );
		else
			$this->edgeSet->removeEdge( $target, $source );
	}
753271
public function package($targetFile, $force)
    {
        if (is_file($targetFile)) {
            if ($force) {
                unlink($targetFile);
            } else {
                throw new \RuntimeException("File {$targetFile} already exists");
            }
        }
        $curDir = getcwd();
        $buildFile = 'build.phar';
        $phar = new \Phar($buildFile);

        if ($static = $this->options['static']) {
            $stub = new Node\StaticStub(
                $phar,
                $this->options['app-name'],
                $this->options['app-version'],
                $this->options['static'],
                $this->options['static-plugin-paths']
            );
        } else {
            $stub = new Node\DynamicStub(
                $phar,
                $this->options['app-name'],
                $this->options['app-version'],
                $this->options['config-filename']
            );
        }
        $buffer = new Buffer();
        $buffer
            ->writeln('#!/usr/bin/env php')
            ->writeln('<?php')
            ->writeln(self::$HEADER)
        ;
        $stub->compile($buffer);

        chdir($this->srcRoot);
        $finder = new Finder();
        $files = $finder
            ->in(array('vendor', 'src'))
            ->ignoreVCS(true)
            // Finder is only used by the packager, not by Z itself.
            ->exclude(array('vendor/symfony/finder'))
            ->files();

        foreach ($files as $file) {
            $phar[$file->getPathname()] = file_get_contents($file->getPathname());
        }
        $phar['LICENSE'] = file_get_contents('LICENSE');
        chdir($curDir);

        $phar->setStub($buffer->getResult());
        rename($buildFile, $targetFile);
        chmod($targetFile, 0755);
        chdir($curDir);

        return realpath($targetFile);
    }
184855
public function move(string $sourceInterface, string $sourceName, string $targetInterface, string $targetName)
    {
        $sourceIndex = $sourceInterface . '-' . $sourceName;
        if (! isset($this->container[$sourceIndex])) {
            throw $this->unbound($sourceIndex);
        }
        $targetIndex = $targetInterface . '-' . $targetName;
        $this->container[$targetIndex] = $this->container[$sourceIndex];
        unset($this->container[$sourceIndex]);
    }