/** * Rename the file * * @param String $oldname the old name * @param String $newname the new name * * @return bool * @throws CMbException */ private function _renameFile($oldname, $newname) { if (!$this->connexion) { throw new CMbException("CSourceSFTP-connexion-failed", $this->hostname); } // Rename the file if (!$this->connexion->rename($oldname, $newname)) { throw new CMbException("CSourceSFTP-rename-file-failed", $oldname, $newname); } return true; }
public function rename($source, $target) { try { if (!$this->is_dir($target) && $this->file_exists($target)) { $this->unlink($target); } return $this->client->rename($this->absPath($source), $this->absPath($target)); } catch (\Exception $e) { return false; } }
/** * Rename a file or directory * * @param $oldName * @param $newName * * @return bool */ public function rename($oldName, $newName) { switch ($this->_connType) { case SftpHelper::TYPE_SFTP: default: $res = $this->_connection->rename($oldName, $newName); break; case SftpHelper::TYPE_FTP: $res = ftp_rename($this->_connection, $oldName, $newName); break; } return $res; }
/** * Rename or move a directory or a file * */ public function mv($src, $dest) { return $this->_connection->rename($src, $dest); }
/** * Attempts to rename path_from to path_to * * Attempts to rename oldname to newname, moving it between directories if necessary. * If newname exists, it will be overwritten. * * @param String $path_from * @param String $path_to * @return bool * @access public */ public function rename($path_from, $path_to) { $path1 = parse_url($path_from); $path2 = parse_url($path_to); unset($path1['path'], $path2['path']); if ($path1 != $path2) { return FALSE; } unset($path1, $path2); $connection = $this->stream_open($path_from, NULL, NULL, $opened_path); if ($connection === false) { return FALSE; } $path_to = parse_url($path_to, PHP_URL_PATH); // "It is an error if there already exists a file with the name specified by newpath." // -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-6.5 if (!$this->sftp->rename($this->path, $path_to)) { if ($this->sftp->stat($path_to)) { $del = $this->sftp->delete($path_to, true); $rename = $this->sftp->rename($this->path, $path_to); $this->stream_close(); return $del && $rename; } } $this->stream_close(); return TRUE; }
/** * Rename or move a directory or a file * * @param string $source * @param string $destination * @return bool */ public function mv($source, $destination) { return $this->_connection->rename($source, $destination); }
public function rename($oldName, $newName) { return $this->conn->rename($oldName, $newName); }