copy the file.

@param $source
@param $des
@return bool
978047
public static function copy($source, $des)
    {
        if (!is_file($source)) {
            return false;
        }
        try {
            @copy($source, $des);
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
383689
protected function _copyDirectory($source, $destination)
    {
        $folder = new Folder($source);
        if ($folder->copy(['to' => $destination])) {
            $this->out('Copied assets to directory ' . $destination);

            return true;
        }

        $this->err('Error copying assets to directory ' . $destination);

        return false;
    }
177825
public static function copyRecursive($source, $destination)
    {
        if (is_dir($source)) {
            $dir_handle = opendir($source);

            while ($file = readdir($dir_handle)) {
                if ($file != "." && $file != "..") {
                    self::mkDir($destination);

                    if (is_dir($source . "/" . $file)) {
                        if (!is_dir($destination . "/" . $file)) {
                            mkdir($destination . "/" . $file);
                        }
                        self::copyRecursive($source . "/" . $file, $destination . "/" . $file);
                    } else {
                        copy($source . "/" . $file, $destination . "/" . $file);
                    }
                }
            }
            closedir($dir_handle);
        } else {
            copy($source, $destination);
        }

        return true;
    }
1157957
private function copyFilesFromSource($source, $destination, $search = true, $replace = true, $allFolders = true)
    {
        // search and replace the default
        if($search === true && $replace === true) {
            $search = [
                'Bpocallaghan\Titan',
                "('titan::"
            ];
            $replace = [
                "App",
                "('"
            ];
        }

        // search and replace namespace prefix and views prefix
        if($search === 'namespace_views' && $replace === true) {
            $search = [
                'namespace Bpocallaghan\Titan',
                "('titan::"
            ];
            $replace = [
                "namespace App",
                "('"
            ];
        }
        
        // destination
        $destination = $this->formatFilePath($destination . $this->ds);

        // is source array
        if (is_array($source)) {
            // if one file
            $files = collect();
            $sources = $source;
            foreach ($sources as $k => $path) {
                // update source
                $pos = strrpos($path, $this->ds, -2) + 1;
                $source = substr($path, 0, $pos);
                $files->push(new SplFileInfo($path, $source, $path));
            }
        }
        // is source a file
        elseif ($this->filesystem->isFile($source)) {
            $files = collect([new SplFileInfo($source, $source, $source)]);
            // update source
            $pos = strrpos($source, $this->ds, -2) + 1;
            $source = substr($source, 0, $pos);
        }
        else {
            // source is directory path
            $source = $this->formatFilePath($source . $this->ds);

            // include sub folders
            if (!$allFolders) {
                $files = collect($this->filesystem->files($source));
            }
            else {
                $files = collect($this->filesystem->allFiles($source));
            }
        }

        $this->line("Destination: {$destination}");

        // can we override the existing files or not
        $override = $this->overrideExistingFiles($files, $source, $destination);

        // loop through all files and copy file to destination
        $files->map(function (SplFileInfo $file) use ($source, $destination, $override, $search, $replace) {

            $subDirectories = '';
            $fileSource = $file->getRealPath();
            //$fileSource = $source . $file->getFilename();
            //$fileSource = $file->getPath() . $this->ds . $file->getFilename();
            $fileDestination = $destination . $file->getFilename();

            // if file is in subdirectory - update destination
            if ($source != $file->getPath() . $this->ds) {
                $subDirectories = str_replace($source, "", $file->getPath() . $this->ds);
                $fileDestination = $destination . $subDirectories . $file->getFilename();
            }

            //dump("$fileSource");
            if (!$this->filesystem->exists($fileSource)) {
                dump("file does not exist? " . $fileSource);

                return;
            }

            // if not exist or if we can override the files
            if ($this->filesystem->exists($fileDestination) == false || $override == true) {

                // make all the directories
                $this->makeDirectory($fileDestination);

                // replace file namespace
                $stub = $this->filesystem->get($fileSource);
                if (is_string($search)) {
                    $stub = str_replace($search, $replace, $stub);
                }
                else if (is_array($search)) {
                    foreach ($search as $k => $value) {
                        $stub = str_replace($value, $replace[$k], $stub);
                    }
                }

                // save modified file to destination
                $this->filesystem->put($fileDestination, $stub);

                // copy (old)
                //$this->filesystem->copy($fileSource, $fileDestination);

                $this->info("File copied: {$subDirectories}{$file->getFilename()}");
            }
            //dump($file->getFilename());
        });
    }
275314
protected function copy($source, $target)
    {
        if (is_file($source)) {
            $exists = is_file($target) ? true :false;
            $this->filesystem->copy($source, $target);

            if (!$exists) {
                return true;
            }
        }

        return false;
    }
1073920
private function copy($source, $target)
    {
        $files = $this->listFiles($source, $target);

        foreach ($files as $newPath => $oldPath) {
            if (!file_exists($newPath)) {
                if (is_dir($oldPath)) {
                    mkdir($newPath, 0755, true);
                } else {
                    copy($oldPath, $newPath);
                }
            }
        }
    }
1310774
public function copyTo($dest, $full = true)
    {
        if ($full) {
            if (strpos($this->path, DIRECTORY_SEPARATOR) !== false) {
                $folder = substr($this->path, (strrpos($this->path, DIRECTORY_SEPARATOR) + 1));
            } else {
                $folder = $this->path;
            }

            if (!file_exists($dest . DIRECTORY_SEPARATOR . $folder)) {
                mkdir($dest . DIRECTORY_SEPARATOR . $folder);
            }
            $dest = $dest . DIRECTORY_SEPARATOR . $folder;
        }

        return static::copy($this->path, $dest, true);
    }
110281
public function copy( $source, $destination ) {

		$source = $this->get_file( $source );

		if ( false === $source ) {
			return false;
		}

		$destination_parent = $this->get_file( dirname( $destination ) );
		$filename = basename( $destination );

		if ( false === $destination_parent ) {
			return false;
		}

		$destination_parent->contents->$filename = clone $source;

		return true;
	}
67999
protected function copyConfigurationFile($source, $target)
    {
        $fs = new Filesystem();
        $fs->copy($source, $target, true);

        if (!$this->output->isQuiet()) {
            $this->output->writeln("Copied $source to $target");
        }
    }
1097431
public function copy($source, $target)
    {
        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);

        if (!file_exists($target)) {
            mkdir($target, 0777, true);
        }

        foreach ($ri as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
            if ($file->isDir()) {
                if (!file_exists($targetPath)) {
                    mkdir($targetPath);
                }
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
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;
    }
1369864
public function copyFiles($source, $target, $files)
    {
        foreach ($files as $file) {
            $this->copyFile($source, $target, $file);
        }
    }
167642
public static function copy($source, $target)
    {
        $source = Normalize::diskFullPath($source);
        $target = Normalize::diskFullPath($target);

        // check if target directory exist & create new if not
        $targetArray = explode(DIRECTORY_SEPARATOR, $target);
        array_pop($targetArray);
        $targetDir = implode(DIRECTORY_SEPARATOR, $targetArray);
        if (!Directory::exist($targetDir)) {
            Directory::create($targetDir, 0777);
        }

        return copy($source, $target);
    }
595113
public function moveImage($source, $dest)
    {
        $dest = str_replace('//', '/', $this->config['upload_path'] . '/' . str_replace($this->config['upload_path'], '', $dest));
        return $this->obj->moveImage($source, $dest);
    }
352712
public function copy( Table $src, Table $dest ) {

		$this->copy_structure( $src, $dest );
		$src_table  = $this->database->quote_identifier( $src->name() );
		$dest_table = $this->database->quote_identifier( $dest->name() );
		$query      = "INSERT INTO {$dest_table} SELECT * FROM {$src_table}";

		return (bool) $this->database->query( $query );
	}
556727
public static function copyFile($source,$dest,$replace=false)
    {
        $dir=dirname($dest);
        if (!file_exists($dir)){//如果文件夹不存在
            self::createDir(dirname($dir));    //取得最后一个文件夹的全路径返回开始的地方
            mkdir($dir, 0777);
            chmod($dir,0777);
        }
        if(file_exists($dest)){
            if($replace)
                unlink($dest);
            else
                return false;
        }
        return copy($source,$dest);
    }
571061
public static function copy($src, $dest, $force = false)
	{
		if (is_dir($src)) {
			Dir::copy($src, $dest, $force);
		} elseif (is_file($src)) {
			File::copy($src, $dest, $force);
		}

		return true;
	}