Perform a clone operation

@param string|null $dest
324179
public function checkout($dest = null)
    {
        $temporary = $this->isTemporary;

        if (true === is_null($dest)) {
            $realdest = $this->cwd;
        } else {
            $realdest = $dest;
        }

        $head = $this->getHead();
        $branch = $head->getName();

        $this->dispatch(VcsEvents::PRE_CHECKOUT, new CheckoutEventData($head, $realdest));

        if (false === $this->hasClone || false === is_null($dest)) {
            $this->cloneRepository($dest);
        } else {
            $this->fetch();

            $result = $this->execute('checkout', array((string) $branch));
        }

        $this->hasCheckout = true;

        $result = $this->pull('origin', $branch);

        $this->dispatch(VcsEvents::POST_CHECKOUT, new CheckoutEventData($head, $realdest));
    }
1164025
public static function copy(StreamInterface $src, StreamInterface $dest)
    {
        if ($src->isSeekable()) {
            $src->rewind();
        }

        while (!$src->eof()) {
            $dest->write($src->read(4096));
        }
    }
672234
public function copyr($source, $dest)
    {
        // Simple copy for a file
        if (is_file($source)) {
            return $this->copy($source, $dest);
        }
        // Make destination directory
        if (!is_dir($dest)) {
            $this->mkdir($dest);
        }
        // Loop through the folder
        $dir = $this->dir($source);
        while ( false !== ($entry = $dir->read()) ) {
            // Skip pointers
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            if (!$this->copyable($entry)) {
                continue;
            }
            // Deep copy directories
            if ($dest !== "$source/$entry") {
                $this->copyr("$source/$entry", "$dest/$entry");
            }
        }
        // Clean up
        $dir->close();
        return true;
    }
637793
public function moveImage($source, $dest)
    {
        $dir = dirname($dest);
        if(!file_exists($dir)){
            mkdir($dir, 0755, true);
        }
        return rename($source, $dest);
    }
677929
def clonetopath(self, dest):
        
        raise Exception(
            "%s.%s needs to implement @classmethod .clonetopath(dest)" % (
                self.__class__.__module__, self.__class__.__name__))
860274
public function save($dest = null, $compress = true)
    {
        if (!file_exists(dirname($dest))) {
            mkdir(dirname($dest), 0755, true);
        }

        file_put_contents($dest, $this->get(null, $compress));
    }
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
            }
        }
    }
623667
protected function copyFileWithDirsCreating($src, $dest)
    {
        $dirPathOfDestFile = dirname($dest);

        if (! File::exists($dirPathOfDestFile)) {
            File::makeDirectory($dirPathOfDestFile, 0755, true);
        }

        if (! File::exists($dest)) {
            File::copy($src, $dest);
        }
    }
1059604
protected function downloadFile($dest, $callback = null)
    {
        $retval = [
            'success' => false,
            'data'    => [],
        ];

        if (is_resource($dest)) {
            $handle = $dest;
            $metadata = stream_get_meta_data($handle);
            $dest = $metadata["uri"];
        } else {
            $dest = rtrim($dest, '/');

            if (file_exists($dest)) {
                if (is_dir($dest)) {
                    $dest = rtrim($dest, '/') . "/{$this['name']}";
                } else {
                    $retval['data']['message'] = "File already exists at '$dest'.";
                    if (is_callable($callback)) {
                        call_user_func($callback, $retval, $dest);
                    }

                    return $retval;
                }
            }

            $handle = @fopen($dest, 'a');

            if (!$handle) {
                throw new \Exception("Unable to open file at '$dest'. Make sure the directory path exists.");
            }
        }

        $response = self::$httpClient->get(
            self::$account->getContentUrl() . "nodes/{$this['id']}/content",
            [
                'headers'    => [
                    'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'],
                ],
                'stream'     => true,
                'exceptions' => false,
            ]
        );

        $retval['data'] = json_decode((string)$response->getBody(), true);

        if ($response->getStatusCode() !== 200) {
            if (is_callable($callback)) {
                call_user_func($callback, $retval, $dest);
            }

            return $retval;
        }

        $retval['success'] = true;

        $body = $response->getBody();
        while (!$body->eof()) {
            fwrite($handle, $body->read(1024));
        }

        fclose($handle);

        if (is_callable($callback)) {
            call_user_func($callback, $retval, $dest);
        }

        return $retval;
    }
620465
function copyRepo(dest) {
  return new Promise((resolve, reject) => {
    ncp('.tmp/repo', dest, (err) => {
      if (err) {
        reject(err)
        return
      }
      resolve()
    })
  })
}
447426
private function drain($stream, $dest)
    {
        if (is_resource($stream)) {
            if (!is_resource($dest)) {
                $stream = Stream::factory($stream);
            } else {
                stream_copy_to_stream($stream, $dest);
                fclose($stream);
                rewind($dest);
                return $dest;
            }
        }

        // Stream the response into the destination stream
        $dest = is_string($dest)
            ? new Stream(Utils::open($dest, 'r+'))
            : Stream::factory($dest);

        Utils::copyToStream($stream, $dest);
        $dest->seek(0);
        $stream->close();

        return $dest;
    }
663727
public function copy(ClassCopyLogger $logger, string $src, string $dest)
    {
        $srcPath = $this->classFileNormalizer->normalizeToFile($src);
        $destPath = $this->classFileNormalizer->normalizeToFile($dest);

        return $this->copyFile($logger, $srcPath, $destPath);
    }
1239842
def copy(self, dest):
        
        if os.path.isfile(self.path):
            shutil.copy2(self.path, dest)
        else:
            shutil.copytree(self.path, dest, symlinks=False, ignore=None)
114910
public function docs($dest = null)
    {
        if (!$dest) {
            $dest = __DIR__ . '/../peridot-php.github.io';
        }
        $src = __DIR__ . '/docs';
        $this->taskDeleteDir([
            $dest . '/docs',
            $src
        ])->run();
        $this->taskExec('apigen generate')->run();
        $this->taskCopyDir([
            $src => $dest . '/docs'
        ])->run();
        $this->taskDeleteDir([$src])->run();
    }
978047
public static function copy($source, $des)
    {
        if (!is_file($source)) {
            return false;
        }
        try {
            @copy($source, $des);
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
248997
function copyData (dest, sourceData) {
  var parsedProperty;
  var key;
  for (key in sourceData) {
    if (sourceData[key] === undefined) { continue; }
    parsedProperty = sourceData[key];
    dest[key] = isObjectOrArray(parsedProperty)
      ? utils.clone(parsedProperty)
      : parsedProperty;
  }
  return dest;
}
855819
public function move($dest = '')
        {
            rename($this->getFilePath(), $dest);
            $this->setFilePath($dest);

            $this->capsule['filepath'] = $dest;
            return $this;
        }