Add some PHPDocs

My IDE was crying...
This commit is contained in:
Lukas Reschke 2015-02-24 13:30:28 +01:00
parent e08ebe87dc
commit dbb665a361
1 changed files with 70 additions and 2 deletions

View File

@ -43,8 +43,9 @@ class SFTP extends \OC\Files\Storage\Common {
*/ */
protected $client; protected $client;
private static $tempFiles = array(); /**
* {@inheritdoc}
*/
public function __construct($params) { public function __construct($params) {
// Register sftp:// // Register sftp://
\Net_SFTP_Stream::register(); \Net_SFTP_Stream::register();
@ -100,6 +101,9 @@ class SFTP extends \OC\Files\Storage\Common {
return $this->client; return $this->client;
} }
/**
* {@inheritdoc}
*/
public function test() { public function test() {
if ( if (
!isset($this->host) !isset($this->host)
@ -111,29 +115,45 @@ class SFTP extends \OC\Files\Storage\Common {
return $this->getConnection()->nlist() !== false; return $this->getConnection()->nlist() !== false;
} }
/**
* {@inheritdoc}
*/
public function getId(){ public function getId(){
return 'sftp::' . $this->user . '@' . $this->host . '/' . $this->root; return 'sftp::' . $this->user . '@' . $this->host . '/' . $this->root;
} }
/**
* @return string
*/
public function getHost() { public function getHost() {
return $this->host; return $this->host;
} }
/**
* @return string
*/
public function getRoot() { public function getRoot() {
return $this->root; return $this->root;
} }
/**
* @return mixed
*/
public function getUser() { public function getUser() {
return $this->user; return $this->user;
} }
/** /**
* @param string $path * @param string $path
* @return string
*/ */
private function absPath($path) { private function absPath($path) {
return $this->root . $this->cleanPath($path); return $this->root . $this->cleanPath($path);
} }
/**
* @return bool|string
*/
private function hostKeysPath() { private function hostKeysPath() {
try { try {
$storage_view = \OCP\Files::getStorage('files_external'); $storage_view = \OCP\Files::getStorage('files_external');
@ -147,6 +167,10 @@ class SFTP extends \OC\Files\Storage\Common {
return false; return false;
} }
/**
* @param $keys
* @return bool
*/
protected function writeHostKeys($keys) { protected function writeHostKeys($keys) {
try { try {
$keyPath = $this->hostKeysPath(); $keyPath = $this->hostKeysPath();
@ -163,6 +187,9 @@ class SFTP extends \OC\Files\Storage\Common {
return false; return false;
} }
/**
* @return array
*/
protected function readHostKeys() { protected function readHostKeys() {
try { try {
$keyPath = $this->hostKeysPath(); $keyPath = $this->hostKeysPath();
@ -186,6 +213,9 @@ class SFTP extends \OC\Files\Storage\Common {
return array(); return array();
} }
/**
* {@inheritdoc}
*/
public function mkdir($path) { public function mkdir($path) {
try { try {
return $this->getConnection()->mkdir($this->absPath($path)); return $this->getConnection()->mkdir($this->absPath($path));
@ -194,6 +224,9 @@ class SFTP extends \OC\Files\Storage\Common {
} }
} }
/**
* {@inheritdoc}
*/
public function rmdir($path) { public function rmdir($path) {
try { try {
return $this->getConnection()->delete($this->absPath($path), true); return $this->getConnection()->delete($this->absPath($path), true);
@ -202,6 +235,9 @@ class SFTP extends \OC\Files\Storage\Common {
} }
} }
/**
* {@inheritdoc}
*/
public function opendir($path) { public function opendir($path) {
try { try {
$list = $this->getConnection()->nlist($this->absPath($path)); $list = $this->getConnection()->nlist($this->absPath($path));
@ -223,6 +259,9 @@ class SFTP extends \OC\Files\Storage\Common {
} }
} }
/**
* {@inheritdoc}
*/
public function filetype($path) { public function filetype($path) {
try { try {
$stat = $this->getConnection()->stat($this->absPath($path)); $stat = $this->getConnection()->stat($this->absPath($path));
@ -239,6 +278,9 @@ class SFTP extends \OC\Files\Storage\Common {
return false; return false;
} }
/**
* {@inheritdoc}
*/
public function file_exists($path) { public function file_exists($path) {
try { try {
return $this->getConnection()->stat($this->absPath($path)) !== false; return $this->getConnection()->stat($this->absPath($path)) !== false;
@ -247,6 +289,9 @@ class SFTP extends \OC\Files\Storage\Common {
} }
} }
/**
* {@inheritdoc}
*/
public function unlink($path) { public function unlink($path) {
try { try {
return $this->getConnection()->delete($this->absPath($path), true); return $this->getConnection()->delete($this->absPath($path), true);
@ -255,6 +300,9 @@ class SFTP extends \OC\Files\Storage\Common {
} }
} }
/**
* {@inheritdoc}
*/
public function fopen($path, $mode) { public function fopen($path, $mode) {
try { try {
$absPath = $this->absPath($path); $absPath = $this->absPath($path);
@ -284,6 +332,9 @@ class SFTP extends \OC\Files\Storage\Common {
return false; return false;
} }
/**
* {@inheritdoc}
*/
public function touch($path, $mtime=null) { public function touch($path, $mtime=null) {
try { try {
if (!is_null($mtime)) { if (!is_null($mtime)) {
@ -300,14 +351,27 @@ class SFTP extends \OC\Files\Storage\Common {
return true; return true;
} }
/**
* @param string $path
* @param string $target
* @throws \Exception
*/
public function getFile($path, $target) { public function getFile($path, $target) {
$this->getConnection()->get($path, $target); $this->getConnection()->get($path, $target);
} }
/**
* @param string $path
* @param string $target
* @throws \Exception
*/
public function uploadFile($path, $target) { public function uploadFile($path, $target) {
$this->getConnection()->put($target, $path, NET_SFTP_LOCAL_FILE); $this->getConnection()->put($target, $path, NET_SFTP_LOCAL_FILE);
} }
/**
* {@inheritdoc}
*/
public function rename($source, $target) { public function rename($source, $target) {
try { try {
if (!$this->is_dir($target) && $this->file_exists($target)) { if (!$this->is_dir($target) && $this->file_exists($target)) {
@ -322,6 +386,9 @@ class SFTP extends \OC\Files\Storage\Common {
} }
} }
/**
* {@inheritdoc}
*/
public function stat($path) { public function stat($path) {
try { try {
$stat = $this->getConnection()->stat($this->absPath($path)); $stat = $this->getConnection()->stat($this->absPath($path));
@ -337,6 +404,7 @@ class SFTP extends \OC\Files\Storage\Common {
/** /**
* @param string $path * @param string $path
* @return string
*/ */
public function constructUrl($path) { public function constructUrl($path) {
// Do not pass the password here. We want to use the Net_SFTP object // Do not pass the password here. We want to use the Net_SFTP object