protected $_key = null;
protected $_connection = null;
protected $_sftp = null;
+ public $convertToCygwinPath = false;
public function __construct($host, $username, $password, $port = 22) {
$this->setHost($host)
return $this->_sftp;
}
+
public function getSFTPWrapper() {
- return 'ssh2.sftp://' . $this->getSFTPConnection() . '/';
+ return 'ssh2.sftp://' . intval($this->getSFTPConnection()) . '/';
}
public function filePutContents($filename, $data) {
}
protected function _filename($filename) {
- return $this->getSFTPWrapper() . ltrim($this->_escapeCygwin($filename), '/');
+ if ($this->convertToCygwinPath) {
+ $filename = $this->_escapeCygwin($filename);
+ }
+ return $this->getSFTPWrapper() . ltrim($filename, '/');
}
public function filesize($filename) {
/**
* @param $local string
- * @param $distant string
+ * @param $remote string
* @param $mode int
* @return bool
*/
- public function send($local, $distant, $mode = 0755) {
- $dir = dirname($distant);
+ public function send($local, $remote, $mode = 0644) {
+ if (!file_exists($local)) {
+ throw new \Exception('Local file ' . $local . ' not found');
+ }
+ $dir = dirname($remote);
$this->mkdir($dir);
- return ssh2_scp_send($this->getSFTPConnection(), $local, $distant, $mode);
+ return copy($local, $this->_filename($remote));
}
/**
- * @param $distant string
+ * @param $remote string
* @param $local string
* @return bool
*/
- public function recv($distant, $local) {
- return ssh2_scp_recv($this->getSFTPConnection(), $distant, $local);
+ public function recv($remote, $local) {
+ return copy($this->_filename($remote), $local);
}