Add some basic PHPDoc to functions

This commit is contained in:
Lukas Reschke 2015-02-18 16:08:30 +01:00
parent 41e5850450
commit 46ca0fa481
1 changed files with 124 additions and 6 deletions

View File

@ -6,6 +6,12 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
namespace OC\Files;
use OC\Files\Cache\Updater;
use OC\Files\Mount\MoveableMount;
/** /**
* Class to provide access to ownCloud filesystem via a "view", and methods for * Class to provide access to ownCloud filesystem via a "view", and methods for
* working with files within that view (e.g. read, write, delete, etc.). Each * working with files within that view (e.g. read, write, delete, etc.). Each
@ -22,12 +28,6 @@
* Filesystem functions are not called directly; they are passed to the correct * Filesystem functions are not called directly; they are passed to the correct
* \OC\Files\Storage\Storage object * \OC\Files\Storage\Storage object
*/ */
namespace OC\Files;
use OC\Files\Cache\Updater;
use OC\Files\Mount\MoveableMount;
class View { class View {
private $fakeRoot = ''; private $fakeRoot = '';
@ -250,11 +250,19 @@ class View {
return $this->basicOperation('opendir', $path, array('read')); return $this->basicOperation('opendir', $path, array('read'));
} }
/**
* @param $handle
* @return mixed
*/
public function readdir($handle) { public function readdir($handle) {
$fsLocal = new Storage\Local(array('datadir' => '/')); $fsLocal = new Storage\Local(array('datadir' => '/'));
return $fsLocal->readdir($handle); return $fsLocal->readdir($handle);
} }
/**
* @param string $path
* @return bool|mixed
*/
public function is_dir($path) { public function is_dir($path) {
if ($path == '/') { if ($path == '/') {
return true; return true;
@ -262,6 +270,10 @@ class View {
return $this->basicOperation('is_dir', $path); return $this->basicOperation('is_dir', $path);
} }
/**
* @param string $path
* @return bool|mixed
*/
public function is_file($path) { public function is_file($path) {
if ($path == '/') { if ($path == '/') {
return false; return false;
@ -269,18 +281,35 @@ class View {
return $this->basicOperation('is_file', $path); return $this->basicOperation('is_file', $path);
} }
/**
* @param string $path
* @return mixed
*/
public function stat($path) { public function stat($path) {
return $this->basicOperation('stat', $path); return $this->basicOperation('stat', $path);
} }
/**
* @param string $path
* @return mixed
*/
public function filetype($path) { public function filetype($path) {
return $this->basicOperation('filetype', $path); return $this->basicOperation('filetype', $path);
} }
/**
* @param string $path
* @return mixed
*/
public function filesize($path) { public function filesize($path) {
return $this->basicOperation('filesize', $path); return $this->basicOperation('filesize', $path);
} }
/**
* @param string $path
* @return bool|mixed
* @throws \OCP\Files\InvalidPathException
*/
public function readfile($path) { public function readfile($path) {
$this->assertPathLength($path); $this->assertPathLength($path);
@ob_end_clean(); @ob_end_clean();
@ -297,18 +326,34 @@ class View {
return false; return false;
} }
/**
* @param string $path
* @return mixed
*/
public function isCreatable($path) { public function isCreatable($path) {
return $this->basicOperation('isCreatable', $path); return $this->basicOperation('isCreatable', $path);
} }
/**
* @param string $path
* @return mixed
*/
public function isReadable($path) { public function isReadable($path) {
return $this->basicOperation('isReadable', $path); return $this->basicOperation('isReadable', $path);
} }
/**
* @param string $path
* @return mixed
*/
public function isUpdatable($path) { public function isUpdatable($path) {
return $this->basicOperation('isUpdatable', $path); return $this->basicOperation('isUpdatable', $path);
} }
/**
* @param string $path
* @return bool|mixed
*/
public function isDeletable($path) { public function isDeletable($path) {
$absolutePath = $this->getAbsolutePath($path); $absolutePath = $this->getAbsolutePath($path);
$mount = Filesystem::getMountManager()->find($absolutePath); $mount = Filesystem::getMountManager()->find($absolutePath);
@ -318,10 +363,18 @@ class View {
return $this->basicOperation('isDeletable', $path); return $this->basicOperation('isDeletable', $path);
} }
/**
* @param string $path
* @return mixed
*/
public function isSharable($path) { public function isSharable($path) {
return $this->basicOperation('isSharable', $path); return $this->basicOperation('isSharable', $path);
} }
/**
* @param string $path
* @return bool|mixed
*/
public function file_exists($path) { public function file_exists($path) {
if ($path == '/') { if ($path == '/') {
return true; return true;
@ -329,10 +382,19 @@ class View {
return $this->basicOperation('file_exists', $path); return $this->basicOperation('file_exists', $path);
} }
/**
* @param string $path
* @return mixed
*/
public function filemtime($path) { public function filemtime($path) {
return $this->basicOperation('filemtime', $path); return $this->basicOperation('filemtime', $path);
} }
/**
* @param string $path
* @param int|string $mtime
* @return bool
*/
public function touch($path, $mtime = null) { public function touch($path, $mtime = null) {
if (!is_null($mtime) and !is_numeric($mtime)) { if (!is_null($mtime) and !is_numeric($mtime)) {
$mtime = strtotime($mtime); $mtime = strtotime($mtime);
@ -360,10 +422,19 @@ class View {
return true; return true;
} }
/**
* @param string $path
* @return mixed
*/
public function file_get_contents($path) { public function file_get_contents($path) {
return $this->basicOperation('file_get_contents', $path, array('read')); return $this->basicOperation('file_get_contents', $path, array('read'));
} }
/**
* @param bool $exists
* @param string $path
* @param bool $run
*/
protected function emit_file_hooks_pre($exists, $path, &$run) { protected function emit_file_hooks_pre($exists, $path, &$run) {
if (!$exists) { if (!$exists) {
\OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_create, array( \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_create, array(
@ -382,6 +453,10 @@ class View {
)); ));
} }
/**
* @param bool $exists
* @param string $path
*/
protected function emit_file_hooks_post($exists, $path) { protected function emit_file_hooks_post($exists, $path) {
if (!$exists) { if (!$exists) {
\OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_create, array( \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_create, array(
@ -397,6 +472,11 @@ class View {
)); ));
} }
/**
* @param string $path
* @param mixed $data
* @return bool|mixed
*/
public function file_put_contents($path, $data) { public function file_put_contents($path, $data) {
if (is_resource($data)) { //not having to deal with streams in file_put_contents makes life easier if (is_resource($data)) { //not having to deal with streams in file_put_contents makes life easier
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
@ -436,6 +516,10 @@ class View {
} }
} }
/**
* @param string $path
* @return bool|mixed
*/
public function unlink($path) { public function unlink($path) {
if ($path === '' || $path === '/') { if ($path === '' || $path === '/') {
// do not allow deleting the root // do not allow deleting the root
@ -572,6 +656,12 @@ class View {
} }
} }
/**
* @param string $path1
* @param string $path2
* @param bool $preserveMtime
* @return bool|mixed
*/
public function copy($path1, $path2, $preserveMtime = false) { public function copy($path1, $path2, $preserveMtime = false) {
$postFix1 = (substr($path1, -1, 1) === '/') ? '/' : ''; $postFix1 = (substr($path1, -1, 1) === '/') ? '/' : '';
$postFix2 = (substr($path2, -1, 1) === '/') ? '/' : ''; $postFix2 = (substr($path2, -1, 1) === '/') ? '/' : '';
@ -697,6 +787,11 @@ class View {
return $this->basicOperation('fopen', $path, $hooks, $mode); return $this->basicOperation('fopen', $path, $hooks, $mode);
} }
/**
* @param string $path
* @return bool|string
* @throws \OCP\Files\InvalidPathException
*/
public function toTmpFile($path) { public function toTmpFile($path) {
$this->assertPathLength($path); $this->assertPathLength($path);
if (Filesystem::isValidPath($path)) { if (Filesystem::isValidPath($path)) {
@ -714,6 +809,12 @@ class View {
} }
} }
/**
* @param string $tmpFile
* @param string $path
* @return bool|mixed
* @throws \OCP\Files\InvalidPathException
*/
public function fromTmpFile($tmpFile, $path) { public function fromTmpFile($tmpFile, $path) {
$this->assertPathLength($path); $this->assertPathLength($path);
if (Filesystem::isValidPath($path)) { if (Filesystem::isValidPath($path)) {
@ -745,11 +846,23 @@ class View {
} }
} }
/**
* @param string $path
* @return mixed
* @throws \OCP\Files\InvalidPathException
*/
public function getMimeType($path) { public function getMimeType($path) {
$this->assertPathLength($path); $this->assertPathLength($path);
return $this->basicOperation('getMimeType', $path); return $this->basicOperation('getMimeType', $path);
} }
/**
* @param string $type
* @param string $path
* @param bool $raw
* @return bool|null|string
*/
public function hash($type, $path, $raw = false) { public function hash($type, $path, $raw = false) {
$postFix = (substr($path, -1, 1) === '/') ? '/' : ''; $postFix = (substr($path, -1, 1) === '/') ? '/' : '';
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
@ -775,6 +888,11 @@ class View {
return null; return null;
} }
/**
* @param string $path
* @return mixed
* @throws \OCP\Files\InvalidPathException
*/
public function free_space($path = '/') { public function free_space($path = '/') {
$this->assertPathLength($path); $this->assertPathLength($path);
return $this->basicOperation('free_space', $path); return $this->basicOperation('free_space', $path);