/** * {@inheritdoc} */ public function getWorkingDirectory() { if ($this->isConnected()) { return $this->connection->pwd(); } return false; }
/** * @param null|string $Name * * @return SFTP\Directory[]|SFTP\File[] */ public function listDirectory($Name = null) { $this->persistConnection(); if (null === $Name) { $Name = $this->Connection->pwd(); } $List = $this->Connection->rawlist($Name); $Return = array(); foreach ($List as $Item => $Attributes) { if ($this->Connection->is_dir($Item)) { $Return[$Item] = new Directory($this, $Attributes); } if ($this->Connection->is_file($Item)) { $Return[$Item] = new File($this, $Attributes); } } return $Return; }
/** * Creates a symlink on the remote server * * @param $src * @param $dest * @throws \RuntimeException * @return mixed */ public function symlink($src, $dest) { if (false === $this->isConnected()) { $this->connectAndLogin(); } $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_SYMLINK, new TransporterEvent($this, array('dest' => $dest, 'src' => $src))); // make src an absolute path if (0 !== strpos($src, '/')) { $src = $this->sftp->pwd() . '/' . $src; } // strip end slashes $src = rtrim($src, '/'); $dest = rtrim($dest, '/'); $success = $this->sftp->exec(sprintf("ln -s -T -f %s %s", escapeshellarg($src), escapeshellarg($dest))); if (false === $success) { throw new \RuntimeException('Something went wrong: ' . "\n" . implode("\n", (array) $this->sftp->getErrors())); } }
/** * Get directory path. * * @return string * * @api */ public function getPwd() : string { return $this->netSftp->pwd(); }