复制文件

@param  string $from
@param  string $to
@param  array  $config

@return bool
763099
public function copy(string $from, string $to, array $config = []): bool
    {
        list($prefixFrom, $from) = $this->getPrefixAndPath($from);

        if (($buffer = $this->getFileSystem($prefixFrom)->readStream($from)) === false) {
            return false;
        }

        unset($prefixFrom, $from);

        list($prefixTo, $to) = $this->getPrefixAndPath($to);

        if ($this->getFileSystem($prefixTo)->writeStream($to, $buffer, $config)) {
            unset($prefixTo, $to, $buffer);
            return true;
        }

        return false;
    }
49102
public function move($from, $to)
    {
        $call = 'fileops/move';
        $params = array(
                'root' => $this->root,
                'from_path' => $this->normalisePath($from),
                'to_path' => $this->normalisePath($to),
        );
        $response = $this->fetch('POST', self::API_URL, $call, $params);
        return $response;
    }
345014
protected function onReleaseReady($from, $to)
    {
        $this->explainer->comment(sprintf('Uploading files from %s to %s', $from, $to));

        // Only gather files from existing folders (for pretend mode)
        $folders = array_filter([$from], 'is_dir');
        if (!$folders) {
            return true;
        }

        $files = (new Finder())->in($folders)->exclude(['.git']);
        $format = $this->explainer->getProgressBarFormat(
            '%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%'.PHP_EOL.
            '%message%'
        );

        // Create progress bar
        $progress = $this->command->createProgressBar(iterator_count($files));
        $progress->setFormat($format);
        $progress->start();

        foreach ($files as $file) {
            $origin = str_replace($from, null, $file->getPathname());
            $path = $to.DS.str_replace($from, null, $file->getPathname());
            $progress->setMessage(
                dirname($origin).DS.
                '<info>'.basename($origin).'</info>'
            );

            if ($file->isDir()) {
                $this->createFolder($path);
            } else {
                $this->put($path, $file->getContents());
            }

            $progress->advance();
        }

        $progress->finish();

        return true;
    }
1181775
final protected function publishFile($from, $to)
    {
        // If destination directory doesn't exist,
        // we'll create before copying the config files
        $directoryDestination = dirname($to);
        if (!$this->files->isDirectory($directoryDestination)) {
            $this->files->makeDirectory($directoryDestination, 0755, true);
        }

        // Copy file to application
        $this->files->copy($from, $to);

        // Output status message
        $this->getCommand()->line(
            sprintf('<info>Copied %s</info> <comment>[%s]</comment> <info>To</info> <comment>[%s]</comment>',
                'File', str_replace(base_path(), '', realpath($from)), str_replace(base_path(), '', realpath($to)))
        );
    }
24236
public function migrateExpiredJobs($from, $to)
    {
        return tap(parent::migrateExpiredJobs($from, $to), function ($jobs) use ($to) {
            $this->event($to, new JobsMigrated($jobs));
        });
    }
536129
public function moveFilesWildcard($from, $to)
    {
        coollect(glob($this->dataDir($from)))->each(function ($from) use ($to) {
            $this->mkDir($dir = $this->dataDir($to));

            rename($from, $dir.'/'.basename($from));
        });
    }
801660
public function move($messages, $from, $to)
    {
        if (!$this->select($from)) {
            return false;
        }

        if (!$this->data['READ-WRITE']) {
            $this->setError(self::ERROR_READONLY, "Mailbox is read-only");
            return false;
        }

        // use MOVE command (RFC 6851)
        if ($this->hasCapability('MOVE')) {
            // Clear last COPYUID data
            unset($this->data['COPYUID']);

            // Clear internal status cache
            unset($this->data['STATUS:'.$to]);
            $this->clear_status_cache($from);

            $result = $this->execute('UID MOVE', array(
                $this->compressMessageSet($messages), $this->escape($to)),
                self::COMMAND_NORESPONSE);

            return $result == self::ERROR_OK;
        }

        // use COPY + STORE +FLAGS.SILENT \Deleted + EXPUNGE
        $result = $this->copy($messages, $from, $to);

        if ($result) {
            // Clear internal status cache
            unset($this->data['STATUS:'.$from]);

            $result = $this->flag($from, $messages, 'DELETED');

            if ($messages == '*') {
                // CLOSE+SELECT should be faster than EXPUNGE
                $this->close();
            }
            else {
                $this->expunge($from, $messages);
            }
        }

        return $result;
    }
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);
        }
    }
140488
public function byRevision(string $from, string $to = ''): Log
    {
        $this->since = ' ' . escapeshellarg($from) . '..'
                     . (empty($to) ? '' : escapeshellarg($to));
        return $this;
    }
703425
protected function publishFile($from, $to)
    {
        if ($this->files->exists($to) || !$this->files->exists($from)) {
            return false;
        }

        $this->files->copy($from, $to);
        $this->info('Stub published: ' . basename($to));

        return true;
    }
1281101
public function getDecompressCommand(LocalFileNodeInterface $from, LocalFileNodeInterface $to)
    {
        return sprintf("gunzip -c %s > %s", escapeshellarg($from->getPath()), escapeshellarg($to->getPath()));
    }
26847
protected static function to_webp_sources(string &$from, &$to) {
		// Validate the source.
		ref\file::path($from, true);
		if (! $from) {
			$from = '';
			return false;
		}

		// We can only convert JPEG, PNG, and GIF sources.
		$info = mime::finfo($from);
		if (! \in_array($info['mime'], array('image/jpeg', 'image/gif', 'image/png'), true)) {
			$from = '';
			return false;
		}

		// Build a destination if we need to.
		if (null !== $to) {
			ref\cast::string($to, true);

			// If this is just a file name, throw it in from's dir.
			if (false === \strpos($to, '/')) {
				$to = "{$info['dirname']}/$to";
			}
			ref\file::path($to, false);
			if ('.webp' !== \substr(\strtolower($to), -5)) {
				$to = '';
				return false;
			}
		}
		// Just swap extensions with the source.
		else {
			$to = "{$info['dirname']}/{$info['filename']}.webp";
		}

		return true;
	}
730057
public function pack($from, $to)
    {
        if (($gzip = gzopen($to, 'wb')) === false) {
            throw new Exception('Unable create compressed file.');
        }

        if (($source = fopen($from, 'rb')) === false) {
            throw new Exception('Unable open the compression source file.');
        }

        while (!feof($source)) {
            $content = fread($source, 4096);
            gzwrite($gzip, $content, strlen($content));
        }

        gzclose($gzip);
        fclose($source);
    }
1040394
public function renameRemoteFile($from, $to)
    {
        if(@ssh2_sftp_rename($this->sftp, $from, $to)){
            throw new \Exception("Could not rename file from $from to $to");
        }

        return true;
    }
141710
public function rename($from, $to)
    {
        if (is_null($key = $this->search($from))) {
            return false;
        }

        $this->items[$key] = $this->getSlugFromName($to);

        return true;
    }
1044503
public function copy($from, $to)
    {
        $pathFrom = $this->pathRoot.ltrim($from, "/");
        $pathTo   = $this->pathRoot.ltrim($to, "/");

        if (is_dir($pathFrom)) {
            return $this->copyDir($pathFrom, $pathTo);
        } else {
            return $this->copyFile($pathFrom, $pathTo);
        }
    }
1364166
public function translate($word, $to, $from = null)
    {
        if (is_null($this->translator)) {
            /** @var string $translator */
            $translator       = config(self::PREFIX_LARAVEL_CONFIG.'translator');
            $this->translator = new Translator('Microsoft', [
                'client_key'       => config(self::PREFIX_LARAVEL_CONFIG.'translators.'.$translator.'.client_key'),
                'default_language' => config(self::PREFIX_LARAVEL_CONFIG.'translators.'.$translator.'.default_language'),
            ]);
        }

        $translation = $this->translator->translate($word, $to, $from);

        if (is_null($translation)) {
            $translation = $word;
        }

        return $translation;
    }