@param null|string $dir
@param null|string $copyTo

@return string
13653
public function package($dir = null, $copyTo = null)
    {
        if (true === $this->getPhpunitService()->hasSupport()) {
            $this->getPhpunitService()->test($dir);
        }

        $box = $this->getJsonService()->parseFile('box.json');
        $file = $box['output'];

        $this->getFilesystemService()->createDirectory(dirname($file));

        $this->getSystemService()->execute('bin/box build', $dir);

        if (null === $copyTo) {
            return $file;
        }

        $this->getSystemService()->execute($this->_('sudo cp %s %s', $file, $copyTo));

        return $file;
    }
208656
public function writeTemplate($dir)
    {
        // Writes down the file
        $fileDir = $dir . '/' . $this->language->getLanguageName() . $this->baseFolder;
        if (!is_dir($fileDir)) {
            mkdir($fileDir);
        }

        return @file_put_contents($fileDir . '/' . $this->fileName . '.html.twig', $this->twigTemplate);
    }
124739
public function ls($dir = null)
    {
        if (null === $this->_ssh_resource) {
            throw new TransportException(sprintf('None SSH connection available.'));
        }

        $dir = $this->_getAbsoluteRemotePath($dir);
        if ('' === $data = $this->exec('ls '.$dir)) {
            return $this->_trigger_error(sprintf('Unable to list remote directory to %s.', $dir));
        }

        $files = array();
        foreach (explode("\n", $data) as $file) {
            $files[] = $dir.'/'.$file;
        }

        return $files;
    }
1333468
public static function copy_dir( $src_dir, $dest_dir ) {
		Process::create( Utils\esc_cmd( "cp -r %s/* %s", $src_dir, $dest_dir ) )->run_check();
	}
1077924
public List<Node> copyDirectory(Node dest) throws DirectoryNotFoundException, CopyException {
        return copyDirectory(dest, new Filter().includeAll());
    }
1068792
private function copyDir($from, $to)
    {
        mkdir($to, 0777, true);
        
        $items = new FilesystemIterator($from);

        foreach ($items as $item)
        {
            $pattern = preg_quote($from, "/");
            $Key = preg_replace("/^{$pattern}/", "", $item);

            $subFrom = strval($item);
            $subTo   = $to.$Key;
            
            if (filetype($item) == 'dir')
            {
                $this->copyDir($subFrom, $subTo);
            } else {
                $this->copyFile($subFrom, $subTo);
            }
        }

        return true;
    }
368553
public static void copyFile(File copyFrom, File copyTo) throws IOException {

		InputStream from = new FileInputStream(copyFrom);
		OutputStream to = new FileOutputStream(copyTo);

		copyStream(from, to);
	}
621268
public static function getFirstLevelDirs($dir)
    {
        $iterator = new DirectoryIterator($dir);
        $result = array();

        foreach ($iterator as $item) {
            if (!$item->isDot() && $item->isDir()) {
                array_push($result, $item->getFileName());
            }
        }

        return $result;
    }
192434
public static void copyStream(InputStream copyFrom, OutputStream copyTo)
			throws IOException {
		copyStream(copyFrom, copyTo, null);
	}
458161
protected function getGitRemoteUrl($dir)
    {
        $this->git->ensureInstalled();
        foreach ([$this->config->get('detection.git_remote_name'), 'origin'] as $remote) {
            if ($url = $this->git->getConfig("remote.$remote.url", $dir)) {
                return $url;
            }
        }

        return false;
    }
1347622
public function copy($to)
	{
		if (is_string($to))
		{
			return $this->hasAdapterOrFail()->adapter->copy($this->getPath(), $to);
		}
		else
		{
			return Manager::copy($this, $to);
		}
	}
393401
public static function emptyContents($dir) {
        $iterator = new \FilesystemIterator($dir, \FilesystemIterator::SKIP_DOTS);
        if (!$iterator->valid()) {
            return;
        }
        foreach($iterator as $fileinfo) {
            if ($fileinfo->isDir()) {
                self::deleteFolder($fileinfo->getPathname());
            }
            else {
                unlink($fileinfo->getPathname());
            }
        }
    }
1179089
protected function writeSshKey($cloneTo)
    {
        $keyPath = dirname($cloneTo . '/temp');
        $keyFile = $keyPath . '.key';

        // Write the contents of this project's git key to the file:
        file_put_contents($keyFile, $this->getProject()->getSshPrivateKey());
        chmod($keyFile, 0600);

        // Return the filename:
        return $keyFile;
    }
409358
public function copyDir($from,$to,Finder $finder)
    {
        /* @var \Symfony\Component\Finder\SplFileInfo $path */

        $finder->in($from);
        foreach ($finder->files() as $path) {
            $targetDir = $to.DIRECTORY_SEPARATOR.$path->getRelativePath();
            if (!is_dir($targetDir)) {
                mkdir($targetDir,0755,true);
            }
            $target = $to.DIRECTORY_SEPARATOR.$path->getRelativePathname();
            copy($path->getRealPath(),$target);
        }
    }
569971
public function listDir($dir='/', $filter=NULL, $hidden=false, $rev=NUll, $type='sandbox')
	{
		$result = $this->metadata($dir, true, false, $hidden, $rev, $type);
		$return = array();
		foreach ($result['contents'] as $item) {
			$exp = explode('/', $item['path']);
			$ext = explode('.', $name = end($exp));
			if (!$filter || preg_match($filter, $name))
				$return[$name] = array(
					'path' => $item['path'],
					'filename' => $name,
					'extension' => (count($ext) > 1) ? array_pop($ext) : null,
					'basename' => implode('.', $ext),
					'mtime'=>strtotime($item['modified']),
					'size' => $item['bytes'],
					'type' => $item['is_dir'] ? 'dir' : 'file',
				);
		}
		return $return;
	}
473147
static function getDir($dir = '.', $ext = NULL) {

		if($dir != '') {
			$dir = rtrim($dir, '/').'/';
		}
		try {
			$i = new \DirectoryIterator($dir);
		} catch (\Exception $e) {
			return false;
		}

		$files = array();

		foreach($i as $file) {
			$fn = $file->getFileName();
			if(!$file->isDot() && $file->isFile() && substr($fn, 0, 1) !== '.') {
				if(!isset($ext) || preg_match("~$ext\$~", $fn)) {
					$files[] = $fn;
				}
			}
		}

		return $files;
	}
620954
public function ls($dir = '/.', $recursive = false, $ignore = array())
    {
        return $this->listItem('file', $dir, $recursive, $ignore);
    }