Call rsync to or from the specified site.

@param string $site_env_id Remote site
@param string $src Source path to copy from. Start with ":" for remote.
@param string $dest Destination path to copy to. Start with ":" for remote.
173765
protected function rsync($site_env_id, $src, $dest, array $rsyncOptions)
    {
        list($site, $env) = $this->getSiteEnv($site_env_id);
        $env_id = $env->getName();

        $siteInfo = $site->serialize();
        $site_id = $siteInfo['id'];

        // Stipulate the temporary directory to use iff the destination is remote.
        $tmpdir = '';
        if ($dest[0] == ':') {
            $tmpdir = '~/tmp';
        }

        $siteAddress = "$env_id.$site_id@appserver.$env_id.$site_id.drush.in:";

        $src = preg_replace('/^:/', $siteAddress, $src);
        $dest = preg_replace('/^:/', $siteAddress, $dest);

        // Get the rsync options string. If the user did not pass
        // in any mode options (e.g. '-r'), then add in the default.
        $rsyncOptionString = implode(' ', $rsyncOptions);
        if (!preg_match('/(^| )-[^-]/', $rsyncOptionString)) {
            $rsyncOptionString = "-rlIpz $rsyncOptionString";
        }
        // Add in a tmp-dir option if one was not already specified
        if (!empty($tmpdir) && !preg_match('/(^| )--temp-dir/', $rsyncOptionString)) {
            $rsyncOptionString = "$rsyncOptionString --temp-dir=$tmpdir --delay-updates";
        }

        $this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsyncOptionString $src $dest"]);
        $this->passthru("rsync $rsyncOptionString --ipv4 --exclude=.git -e 'ssh -p 2222' '$src' '$dest' ");
    }
1145194
public static function rename($src, $dest, $fsencoding = '') {
        $src = strval($src);
        if ($src == '') {
            return;
        }
        $src = self::conv_to($src, $fsencoding);
        $dest = self::conv_to($dest, $fsencoding);
        $dest_dir = self::conv_to(dirname($dest), $fsencoding);
        self::mkdir($dest_dir);
        \rename($src, $dest);
    }
1186341
public static void copyFile(File src, File dest) throws IOException {

        if (src == null)
            throw new NullPointerException("Source must not be null");
        if (dest == null)
            throw new NullPointerException("Destination must not be null");
        if (!src.exists())
            throw new FileNotFoundException("Source '" + src + "' does not exist");
        if (!src.isFile())
            throw new IOException("Source '" + src + "' is not a file");
        if (dest.exists())
            throw new IOException("Destination '" + dest + "' is already exists");

        FileChannel in = null, out = null;
        try {
            in = new FileInputStream(src).getChannel();
            out = new FileOutputStream(dest).getChannel();

            in.transferTo(0, in.size(), out);
        } finally {
            try {
                in.close();
                out.close();
            } catch (IOException e) {
                // Ignore.
            }
        }

        if (src.length() != dest.length()) {
            throw new IOException("Failed to copy full contents from '" +
                src + "' to '" + dest + "'");
        }

        dest.setLastModified(src.lastModified());
    }
104252
public static function copy(string $source, string $dest, bool $overwrite = true): void
	{
		NetteFileSystem::copy($source, $dest, $overwrite);
	}
937569
public function MoveFolder($source,$dest){
        $this->CopyFiles($source,$dest);
        $this->RemoveFiles($source);
    }
620657
private function copy(array $sources, $dest, $minify)
    {
        // create destination path if not exists

        $ext = pathinfo($dest, PATHINFO_EXTENSION);
        $dir = !empty($ext) ? dirname($dest) : $dest;
        if (!file_exists($dir)) {
            if (!make_dir($dir, 0775)) {
                throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
            }
        }

        // list all source files into a flat array

        $files = [];
        foreach ($sources as $source) {
            if (is_dir($source)) {
                if ($ext == 'js') {
                    $filter = ['js'];
                }
                else if ($ext == 'css') {
                    $filter = ['css', 'less', 'scss'];
                }
                else {
                    $filter = null;
                }
                list_files($files, $source, $filter);
            }
            else {
                $files[] = $source;
            }
        }

        // copy all files to the destination

        if (file_exists($dest) && !is_dir($dest)) {
            unlink($dest);
        } // @codeCoverageIgnore

        foreach ($files as $file) {
            // get content
            $content = file_get_contents($file);

            // compile
            $srcExt = pathinfo($file, PATHINFO_EXTENSION);
            switch ($srcExt) {
                case 'less':
//                    $content = (new LessCompiler)->compile($content);
                    $content = (new LessCompiler)->parse($content)->getCss();
                    break;
                case 'scss':
                    $content = (new SCSSCompiler)->compile($content);
                    break;
            }

            // minimize
            if ($minify) {
                switch ($srcExt) {
                    case 'js':
                        $content = JSMin::minify($content);
                        break;
                    case 'css':
                    case 'less':
                    case 'scss':
                        $content = CssMin::minify($content);
                        break;
                }
            }

            // save content
            if (is_dir($dest)) {
                $success = file_put_contents($dest . DIRECTORY_SEPARATOR . basename($file), $content, LOCK_EX);
                //@chmod($dest . DIRECTORY_SEPARATOR . basename($file), 0664);
            }
            else {
                // concatenate the files to a single file
                if (file_exists($dest)) {
                    $success = file_put_contents($dest, PHP_EOL . $content, FILE_APPEND | LOCK_EX);
                }
                else {
                    $success = file_put_contents($dest, $content, LOCK_EX);
                    //@chmod($dest, 0664);
                }
            }
            if ($success === false) {
                throw new RuntimeException(sprintf('Asset Manager was not able to copy "%s" to "%s"', $file, $dest)); // @codeCoverageIgnore
            }
        }
    }
1167111
public static function copyDir($src, $dst)
    {
        if (is_link($src)) {
            symlink(readlink($src), $dst);
        } elseif (is_dir($src)) {
            if (is_dir($dst) === false) {
                mkdir($dst, 0775, true);
            }
            // copy files recursive
            foreach (scandir($src) as $file) {
                if ($file != '.' && $file != '..') {
                    FileSystem::copyDir("$src/$file", "$dst/$file");
                }
            }

        } elseif (is_file($src)) {
            copy($src, $dst);
        } else {
            // do nothing, we didn't have a directory to copy
        }
    }
1048363
public function createDatabaseBackup($site, $env, $db)
    {
        $variables = array(
            'site' => $site,
            'env' => $env,
            'db' => $db,
        );
        $request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/dbs/{db}/backups.json', $variables));
        return new Response\Task($request);
    }
653805
public function environment($site, $env)
    {
        $variables = array(
            'site' => $site,
            'env' => $env,
        );
        $request = $this->get(array('{+base_path}/sites/{site}/envs/{env}.json', $variables));
        return new Response\Environment($request);
    }
916896
def move(src, dest, user=None):
    
    src_host, src_port, src_path = path.split(src, user)
    dest_host, dest_port, dest_path = path.split(dest, user)
    src_fs = hdfs(src_host, src_port, user)
    dest_fs = hdfs(dest_host, dest_port, user)
    try:
        retval = src_fs.move(src_path, dest_fs, dest_path)
        return retval
    finally:
        src_fs.close()
        dest_fs.close()
1186935
public static function copyFile($src, $dst, $newFileMode = null)
    {
        copy($src, $dst);
        if (null !== $newFileMode) {
            @chmod($dst, $newFileMode);
        }
    }
424286
public function make($src, $dest)
    {
        $windows = PlatformHelper::isWindows();

        $src  = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $src);
        $dest = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $dest);

        if ($windows) {
            return exec("mklink /D {$dest} {$src}");
        } else {
            return exec("ln -s {$src} {$dest}");
        }
    }
587821
protected function copy($src, $dest, &$errors = 0, &$success = 0)
    {
        if (is_file($src)) {

            if (copy($src, $dest)) {
                $success++;
                return true;
            }

            $errors++;
            return false;
        }

        if (!is_dir($dest) && !mkdir($dest)) {
            $errors++;
            return false;
        }

        foreach (new DirectoryIterator($src) as $file) {

            $result = null;
            $copyto = "$dest/" . $file->getBasename();

            if ($file->isFile() || (!$file->isDot() && $file->isDir())) {
                $result = $this->copy($file->getRealPath(), $copyto, $errors, $success);
            }

            if (!isset($result)) {
                continue;
            }

            if ($result) {
                $success++;
            } else {
                $errors++;
            }
        }

        $success++;
        return true;
    }
407810
static function rename($src, $dest) {
        if (self::exists($dest)) {
            throw new \Lollipop\Exception\Runtime('File already exists: ' . $dest);
        }
        
        if (is_uploaded_file($src)) {
            return \move_uploaded_file($src, $dest);
        }
        
        return \rename($src, $dest);
    }
996835
public static function copyRecDir($source, $dest) {
    if (!is_dir($dest)) {
      self::mkdirRec($dest);
    }
    $dir = opendir($source);
    while ($file = readdir($dir)) {
      if ($file == "." || $file == "..") {
        continue;
      }
      self::copyRec("$source/$file", "$dest/$file");
    }
    closedir($dir);
  }
1077921
def destination(dest)
      dest = @site.in_dest_dir(dest)
      @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
    end
612057
public static function copyr($src, $dst)
    {
        $dir = opendir($src);
        GeneratorHelper::createDir($dst);
        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                if (is_dir($src . '/' . $file)) {
                    self::copyr($src . '/' . $file, $dst . '/' . $file);
                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
                }
            }
        }
        closedir($dir);
    }