GC_Filesystem_SSH2::move()

最后更新于:2021-11-27 20:36:29

GC_Filesystem_SSH2::move( string$source, string$destination, bool$overwrite=false)

Moves a file.

参数

$source

(string) (Required) Path to the source file.

$destination

(string) (Required) Path to the destination file.

$overwrite

(bool) (Optional) Whether to overwrite the destination file if it exists.

Default value: false

响应

(bool) True on success, false on failure.

源文件

文件: gc-admin/includes/class-gc-filesystem-ssh2.php

	public function move( $source, $destination, $overwrite = false ) {
		if ( $this->exists( $destination ) ) {
			if ( $overwrite ) {
				// We need to remove the destination file before we can rename the source.
				$this->delete( $destination, false, 'f' );
			} else {
				// If we're not overwriting, the rename will fail, so return early.
				return false;
			}
		}

		return ssh2_sftp_rename( $this->sftp_link, $source, $destination );
	}