@param string $src
@param string $dest
@param Theme  $theme

@throws \RuntimeException
186807
public function build($src, $dest, Theme $theme)
    {
        $this->filesystem->purge($dest);

        foreach ($theme->getCopyFiles() as $from => $to) {
            $this->filesystem->copy($from, $dest . '/' . $to);
        }

        $treeItems = $this->parse(new SplFileInfo($src), $dest);
        $theme->setTreeItems($treeItems);

        //build all doc pages
        foreach ($treeItems as $item) {
            $this->exportFile($item, $theme);
        }

        //build index page
        if (!$this->filesystem->exists($dest . '/index.html')) {
            $theme->setCurrentItem('index', '');
            $html = $this->renderTemplate($theme);
            $this->filesystem->writeFile($dest . '/index.html', $html);
        }
    }
462808
public function copy_structure( Table $src, Table $dest ) {

		$src_table  = $this->database->quote_identifier( $src->name() );
		$dest_table = $this->database->quote_identifier( $dest->name() );
		$statement  = new \WpDbTools\Type\GenericStatement(
			"CREATE TABLE {$dest_table} LIKE {$src_table}"
		);

		// this will always return 0 even on error
		$this->database->query( $statement );

		return TRUE;
	}
782344
public static function recurseCopyIfEdited($src = '', $dst = '', array $excludes = ['php'])
    {
        if (!is_dir($dst) && (!mkdir($dst) && !is_dir($dst))) {
            throw new Exception('Copy dir error, access denied for path: '.$dst);
        }

        $dir = opendir($src);
        if (!$dir) {
            throw new Exception('Unable to read dir: '.$src);
        }

        while (false !== ($file = readdir($dir))) {
            if ($file === '.' || $file === '..') {
                continue;
            }

            if (is_dir($src.'/'.$file)) {
                self::recurseCopyIfEdited($src.'/'.$file, $dst.'/'.$file, $excludes);
                continue;
            }

            if (in_array(substr($file, strrpos($file, '.') + 1), $excludes, null)) {
                continue;
            }


            if (file_exists($dst.'/'.$file) && (filemtime($src.'/'.$file) === filemtime($dst.'/'.$file))) {
                continue;
            }

            copy($src.'/'.$file, $dst.'/'.$file);
            chmod($dst.'/'.$file, 0666);
        }
        closedir($dir);
    }
655482
public function processFile($src, $dst, $vars) {
		if(!$this->overrideFiles && file_exists($dst))
			return;
		$container = $this->container;

		$_src = $src;
		$_dst = $dst;
		extract($vars);

		ob_start();
		include $_src;
		$content = ob_get_contents();
		ob_end_clean();

		$content = str_replace('<%=', '<?=', $content);
		$content = str_replace('<%', '<?php', $content);
		$content = str_replace('%>', '?>', $content);

		\Asgard\File\FileSystem::write($_dst, $content);
	}
336850
public void toWEBP(String src, String dest) {
        toWEBP(new File(src), new File(dest));
    }
1216106
protected function loadViewsFromTheme(Theme $theme)
    {
        $views = $theme->getViewDirectory();

        $this->loadViewsFrom($views, $theme->getName());
        $this->loadViewsFrom($views.'/boomcms', 'boomcms');
        $this->loadViewsFrom($views.'/chunks', 'boomcms.chunks');
    }
304640
public static function rcopy($src, $dest)
    {

        // If the src is not a directory do a simple file copy
        if (!is_dir($src)) {
            copy($src, $dest);
            return true;
        }

        // If the destination directory does not exist create it
        if (!is_dir($dest)) {
            static::create($dest);
        }

        // Open the source directory to read in files
        $i = new \DirectoryIterator($src);
        /** @var \DirectoryIterator $f */
        foreach ($i as $f) {
            if ($f->isFile()) {
                copy($f->getRealPath(), "{$dest}/" . $f->getFilename());
            } else {
                if (!$f->isDot() && $f->isDir()) {
                    static::rcopy($f->getRealPath(), "{$dest}/{$f}");
                }
            }
        }
        return true;
    }
786070
static void move(File src, File dest) throws IOException {
        try {
            Files.move(src.toPath(), dest.toPath());
        } catch (IOException x) {
            throw x;
        } catch (Exception x) {
            throw new IOException(x);
        }
    }
80640
private function _setEvent($src = null) {
        if (empty($GLOBALS['eventListeners'])) {
            $GLOBALS['eventListeners'] = [];
        }

        if ($src != null) {
            $path = SRC_PATH . $src . '/' . SRC_RESOURCE_EVENT_PATH;
        }
        else {
            $path = APP_RESOURCE_EVENT_PATH;
        }

        if ($handle = opendir($path)) {
            while (false !== ($entry = readdir($handle))) {
                if (preg_match('#(\.php$)$#isU', $entry)) {
                    if (!array_key_exists($path . $entry, $GLOBALS['eventListeners'])) {
                        include_once($path . $entry);

                        if ($src != null) {
                            $event = '\Event\\' . $src . '\\' . preg_replace('#(.+)' . preg_quote('.php') . '#', '$1', $entry);
                            $event = preg_replace('#' . preg_quote('/') . '#', '\\', $event);
                        }
                        else {
                            $event = '\Event\\' . preg_replace('#(.+)' . preg_quote('.php') . '#', '$1', $entry);
                            $event = preg_replace('#' . preg_quote('/') . '#', '\\', $event);
                        }

                        $GLOBALS['eventListeners']['' . $path . $entry . ''] = new $event();
                    }
                }
            }

            closedir($handle);
        }
    }
1039159
public static void resourceToFile(String resourceName, File dest, Class src) {

		InputStream is = null;
	    OutputStream os = null;
	    try {
	        is = src.getClassLoader().getResourceAsStream(resourceName);
	        if (is == null) {
	            throw new RuntimeException("Could not load resource: " + resourceName);
	        }
	        dest.getParentFile().mkdirs();
	        os = new FileOutputStream(dest);

	        IOUtils.copy(is, os);

	    } catch (Exception e) {
	    	throw new RuntimeException("Error copying resource '" + resourceName + "' to file '"
	    					+ dest.getPath() + "': "+ e, e);
		}
	    finally {
	        IOUtils.closeQuietly(is);
	        IOUtils.closeQuietly(os);
	    }
	}
700072
protected function preserveAlpha($dest, $src)
    {
        $transparent = @imagecolortransparent($src);
        if (-1 != $transparent) {
            $color = @imagecolorsforindex($src, $transparent);
            $allocated = @imagecolorallocatealpha(
                            $dest
                            , $color['red']
                            , $color['green']
                            , $color['blue']
                            , $color['alpha']
            );
            @imagecolortransparent($dest, $allocated);
            @imagefill($dest, 0, 0, $allocated);
        }
    }
176448
private static function appendIfPresent($src, $key, $dest)
    {
        if (!empty($src[$key])) {
            return array_merge($dest, $src[$key]);
        } else {
            return $dest;
        }
    }
97323
public function copy(PhingFile $src, PhingFile $dest)
    {
        global $php_errormsg;

        if (!$src->isLink()) {
            parent::copy($src, $dest);
            return;
        }

        $srcPath = $src->getAbsolutePath();
        $destPath = $dest->getAbsolutePath();

        $linkTarget = $src->getLinkTarget();
        if (false === @symlink($linkTarget, $destPath)) {
            $msg = "FileSystem::copy() FAILED. Cannot create symlink from $destPath to $linkTarget.";
            throw new Exception($msg);
        }
    }
1060131
public static function mirror($source, $dest, PackageEvent $event)
    {
        if (realpath($source) === realpath($dest)) {
            return;
        }
        $fs = new Filesystem();
        try {
            $fs->mirror($source, $dest);
        } catch (IOException $e) {
            $event->getIO()->writeError(sprintf('Mirroring %s to %s failed:', $source, $dest));
            $event->getIO()->writeError($e->getMessage());
        }
    }
123977
public function fileMove($src, $dst, $overwrite = false)
    {
        $src = $this->alias->resolve($src);
        $dst = $this->alias->resolve($dst);

        if (rtrim($dst, '\\/') !== $dst) {
            $dst .= basename($src);
        }

        if (!$overwrite && is_file($dst)) {
            throw new RuntimeException(['move `:src` to `:dst` failed: file exists already', 'src' => $src, 'dst' => $dst]);
        }

        if (!is_dir($dir = dirname($dst))) {
            $this->_dirCreate($dir);
        }

        if (!rename($src, $dst)) {
            throw new RuntimeException(['move `:src` to `:dst` failed: :last_error_message', 'src' => $src, 'dst' => $dst]);
        }
    }
154114
private function setFormTheme(FormView $formView, array $theme = null): void
    {
        $twig = $this->get('twig');

        // BC for Symfony < 3.2 where this runtime does not exists
        if (!method_exists(AppVariable::class, 'getToken')) {
            $twig->getExtension(FormExtension::class)->renderer->setTheme($formView, $theme);

            return;
        }

        // BC for Symfony < 3.4 where runtime should be TwigRenderer
        if (!method_exists(DebugCommand::class, 'getLoaderPaths')) {
            $twig->getRuntime(TwigRenderer::class)->setTheme($formView, $theme);

            return;
        }

        $twig->getRuntime(FormRenderer::class)->setTheme($formView, $theme);
    }
769608
public function copy(PhingFile $src, PhingFile $dest)
    {
        global $php_errormsg;

        // Recursively copy a directory
        if ($src->isDirectory()) {
            $this->copyr($src->getAbsolutePath(), $dest->getAbsolutePath());
        }

        $srcPath = $src->getAbsolutePath();
        $destPath = $dest->getAbsolutePath();

        if (false === @copy($srcPath, $destPath)) { // Copy FAILED. Log and return err.
            // Add error from php to end of log message. $php_errormsg.
            $msg = "FileSystem::copy() FAILED. Cannot copy $srcPath to $destPath. $php_errormsg";
            throw new IOException($msg);
        }

        $dest->setMode($src->getMode());
    }