*/
protected $client;
- private static $tempFiles = array();
-
+ /**
+ * {@inheritdoc}
+ */
public function __construct($params) {
// Register sftp://
\Net_SFTP_Stream::register();
return $this->client;
}
+ /**
+ * {@inheritdoc}
+ */
public function test() {
if (
!isset($this->host)
return $this->getConnection()->nlist() !== false;
}
+ /**
+ * {@inheritdoc}
+ */
public function getId(){
return 'sftp::' . $this->user . '@' . $this->host . '/' . $this->root;
}
+ /**
+ * @return string
+ */
public function getHost() {
return $this->host;
}
+ /**
+ * @return string
+ */
public function getRoot() {
return $this->root;
}
+ /**
+ * @return mixed
+ */
public function getUser() {
return $this->user;
}
/**
* @param string $path
+ * @return string
*/
private function absPath($path) {
return $this->root . $this->cleanPath($path);
}
+ /**
+ * @return bool|string
+ */
private function hostKeysPath() {
try {
$storage_view = \OCP\Files::getStorage('files_external');
return false;
}
+ /**
+ * @param $keys
+ * @return bool
+ */
protected function writeHostKeys($keys) {
try {
$keyPath = $this->hostKeysPath();
return false;
}
+ /**
+ * @return array
+ */
protected function readHostKeys() {
try {
$keyPath = $this->hostKeysPath();
return array();
}
+ /**
+ * {@inheritdoc}
+ */
public function mkdir($path) {
try {
return $this->getConnection()->mkdir($this->absPath($path));
}
}
+ /**
+ * {@inheritdoc}
+ */
public function rmdir($path) {
try {
return $this->getConnection()->delete($this->absPath($path), true);
}
}
+ /**
+ * {@inheritdoc}
+ */
public function opendir($path) {
try {
$list = $this->getConnection()->nlist($this->absPath($path));
}
}
+ /**
+ * {@inheritdoc}
+ */
public function filetype($path) {
try {
$stat = $this->getConnection()->stat($this->absPath($path));
return false;
}
+ /**
+ * {@inheritdoc}
+ */
public function file_exists($path) {
try {
return $this->getConnection()->stat($this->absPath($path)) !== false;
}
}
+ /**
+ * {@inheritdoc}
+ */
public function unlink($path) {
try {
return $this->getConnection()->delete($this->absPath($path), true);
}
}
+ /**
+ * {@inheritdoc}
+ */
public function fopen($path, $mode) {
try {
$absPath = $this->absPath($path);
return false;
}
+ /**
+ * {@inheritdoc}
+ */
public function touch($path, $mtime=null) {
try {
if (!is_null($mtime)) {
return true;
}
+ /**
+ * @param string $path
+ * @param string $target
+ * @throws \Exception
+ */
public function getFile($path, $target) {
$this->getConnection()->get($path, $target);
}
+ /**
+ * @param string $path
+ * @param string $target
+ * @throws \Exception
+ */
public function uploadFile($path, $target) {
$this->getConnection()->put($target, $path, NET_SFTP_LOCAL_FILE);
}
+ /**
+ * {@inheritdoc}
+ */
public function rename($source, $target) {
try {
if (!$this->is_dir($target) && $this->file_exists($target)) {
}
}
+ /**
+ * {@inheritdoc}
+ */
public function stat($path) {
try {
$stat = $this->getConnection()->stat($this->absPath($path));
/**
* @param string $path
+ * @return string
*/
public function constructUrl($path) {
// Do not pass the password here. We want to use the Net_SFTP object