From a22f9ff301312bb24332edaacfb65c280cd8fcd8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 1 Sep 2013 19:47:48 +0200 Subject: Provide an implementation of the fileapi for oc6 build on top of the old api --- lib/files/node/file.php | 155 ++++++++++++++ lib/files/node/folder.php | 382 +++++++++++++++++++++++++++++++++++ lib/files/node/node.php | 247 ++++++++++++++++++++++ lib/files/node/nonexistingfile.php | 89 ++++++++ lib/files/node/nonexistingfolder.php | 113 +++++++++++ lib/files/node/root.php | 337 ++++++++++++++++++++++++++++++ 6 files changed, 1323 insertions(+) create mode 100644 lib/files/node/file.php create mode 100644 lib/files/node/folder.php create mode 100644 lib/files/node/node.php create mode 100644 lib/files/node/nonexistingfile.php create mode 100644 lib/files/node/nonexistingfolder.php create mode 100644 lib/files/node/root.php (limited to 'lib/files/node') diff --git a/lib/files/node/file.php b/lib/files/node/file.php new file mode 100644 index 00000000000..0ad5d68ec66 --- /dev/null +++ b/lib/files/node/file.php @@ -0,0 +1,155 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Node; + +use OC\Files\NotPermittedException; + +class File extends Node { + /** + * @return string + * @throws \OC\Files\NotPermittedException + */ + public function getContent() { + if ($this->checkPermissions(\OCP\PERMISSION_READ)) { + /** + * @var \OC\Files\Storage\Storage $storage; + */ + return $this->view->file_get_contents($this->path); + } else { + throw new NotPermittedException(); + } + } + + /** + * @param string $data + * @throws \OC\Files\NotPermittedException + */ + public function putContent($data) { + if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { + $this->sendHooks(array('preWrite')); + $this->view->file_put_contents($this->path, $data); + $this->sendHooks(array('postWrite')); + } else { + throw new NotPermittedException(); + } + } + + /** + * @return string + */ + public function getMimeType() { + return $this->view->getMimeType($this->path); + } + + /** + * @param string $mode + * @return resource + * @throws \OC\Files\NotPermittedException + */ + public function fopen($mode) { + $preHooks = array(); + $postHooks = array(); + $requiredPermissions = \OCP\PERMISSION_READ; + switch ($mode) { + case 'r+': + case 'rb+': + case 'w+': + case 'wb+': + case 'x+': + case 'xb+': + case 'a+': + case 'ab+': + case 'w': + case 'wb': + case 'x': + case 'xb': + case 'a': + case 'ab': + $preHooks[] = 'preWrite'; + $postHooks[] = 'postWrite'; + $requiredPermissions |= \OCP\PERMISSION_UPDATE; + break; + } + + if ($this->checkPermissions($requiredPermissions)) { + $this->sendHooks($preHooks); + $result = $this->view->fopen($this->path, $mode); + $this->sendHooks($postHooks); + return $result; + } else { + throw new NotPermittedException(); + } + } + + public function delete() { + if ($this->checkPermissions(\OCP\PERMISSION_DELETE)) { + $this->sendHooks(array('preDelete')); + $this->view->unlink($this->path); + $nonExisting = new NonExistingFile($this->root, $this->view, $this->path); + $this->root->emit('\OC\Files', 'postDelete', array($nonExisting)); + $this->exists = false; + } else { + throw new NotPermittedException(); + } + } + + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function copy($targetPath) { + $targetPath = $this->normalizePath($targetPath); + $parent = $this->root->get(dirname($targetPath)); + if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) { + $nonExisting = new NonExistingFile($this->root, $this->view, $targetPath); + $this->root->emit('\OC\Files', 'preCopy', array($this, $nonExisting)); + $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); + $this->view->copy($this->path, $targetPath); + $targetNode = $this->root->get($targetPath); + $this->root->emit('\OC\Files', 'postCopy', array($this, $targetNode)); + $this->root->emit('\OC\Files', 'postWrite', array($targetNode)); + return $targetNode; + } else { + throw new NotPermittedException(); + } + } + + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function move($targetPath) { + $targetPath = $this->normalizePath($targetPath); + $parent = $this->root->get(dirname($targetPath)); + if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) { + $nonExisting = new NonExistingFile($this->root, $this->view, $targetPath); + $this->root->emit('\OC\Files', 'preRename', array($this, $nonExisting)); + $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); + $this->view->rename($this->path, $targetPath); + $targetNode = $this->root->get($targetPath); + $this->root->emit('\OC\Files', 'postRename', array($this, $targetNode)); + $this->root->emit('\OC\Files', 'postWrite', array($targetNode)); + $this->path = $targetPath; + return $targetNode; + } else { + throw new NotPermittedException(); + } + } + + /** + * @param string $type + * @param bool $raw + * @return string + */ + public function hash($type, $raw = false) { + return $this->view->hash($type, $this->path, $raw); + } +} diff --git a/lib/files/node/folder.php b/lib/files/node/folder.php new file mode 100644 index 00000000000..f710ae5ae9a --- /dev/null +++ b/lib/files/node/folder.php @@ -0,0 +1,382 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Node; + +use OC\Files\Cache\Cache; +use OC\Files\Cache\Scanner; +use OC\Files\NotFoundException; +use OC\Files\NotPermittedException; + +class Folder extends Node { + /** + * @param string $path path relative to the folder + * @return string + * @throws \OC\Files\NotPermittedException + */ + public function getFullPath($path) { + if (!$this->isValidPath($path)) { + throw new NotPermittedException(); + } + return $this->path . $this->normalizePath($path); + } + + /** + * @param string $path + * @throws \OC\Files\NotFoundException + * @return string + */ + public function getRelativePath($path) { + if ($this->path === '' or $this->path === '/') { + return $this->normalizePath($path); + } + if (strpos($path, $this->path) !== 0) { + throw new NotFoundException(); + } else { + $path = substr($path, strlen($this->path)); + if (strlen($path) === 0) { + return '/'; + } else { + return $this->normalizePath($path); + } + } + } + + /** + * check if a node is a (grand-)child of the folder + * + * @param \OC\Files\Node\Node $node + * @return bool + */ + public function isSubNode($node) { + return strpos($node->getPath(), $this->path . '/') === 0; + } + + /** + * get the content of this directory + * + * @throws \OC\Files\NotFoundException + * @return Node[] + */ + public function getDirectoryListing() { + $result = array(); + + /** + * @var \OC\Files\Storage\Storage $storage + */ + list($storage, $internalPath) = $this->view->resolvePath($this->path); + if ($storage) { + $cache = $storage->getCache($internalPath); + $permissionsCache = $storage->getPermissionsCache($internalPath); + + //trigger cache update check + $this->view->getFileInfo($this->path); + + $files = $cache->getFolderContents($internalPath); + $permissions = $permissionsCache->getDirectoryPermissions($this->getId(), $this->root->getUser()->getUID()); + } else { + $files = array(); + } + + //add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders + $mounts = $this->root->getMountsIn($this->path); + $dirLength = strlen($this->path); + foreach ($mounts as $mount) { + $subStorage = $mount->getStorage(); + if ($subStorage) { + $subCache = $subStorage->getCache(''); + + if ($subCache->getStatus('') === Cache::NOT_FOUND) { + $subScanner = $subStorage->getScanner(''); + $subScanner->scanFile(''); + } + + $rootEntry = $subCache->get(''); + if ($rootEntry) { + $relativePath = trim(substr($mount->getMountPoint(), $dirLength), '/'); + if ($pos = strpos($relativePath, '/')) { + //mountpoint inside subfolder add size to the correct folder + $entryName = substr($relativePath, 0, $pos); + foreach ($files as &$entry) { + if ($entry['name'] === $entryName) { + if ($rootEntry['size'] >= 0) { + $entry['size'] += $rootEntry['size']; + } else { + $entry['size'] = -1; + } + } + } + } else { //mountpoint in this folder, add an entry for it + $rootEntry['name'] = $relativePath; + $rootEntry['storageObject'] = $subStorage; + + //remove any existing entry with the same name + foreach ($files as $i => $file) { + if ($file['name'] === $rootEntry['name']) { + $files[$i] = null; + break; + } + } + $files[] = $rootEntry; + } + } + } + } + + foreach ($files as $file) { + if ($file) { + if (isset($permissions[$file['fileid']])) { + $file['permissions'] = $permissions[$file['fileid']]; + } + $node = $this->createNode($this->path . '/' . $file['name'], $file); + $result[] = $node; + } + } + + return $result; + } + + /** + * @param string $path + * @param array $info + * @return File|Folder + */ + protected function createNode($path, $info = array()) { + if (!isset($info['mimetype'])) { + $isDir = $this->view->is_dir($path); + } else { + $isDir = $info['mimetype'] === 'httpd/unix-directory'; + } + if ($isDir) { + return new Folder($this->root, $this->view, $path); + } else { + return new File($this->root, $this->view, $path); + } + } + + /** + * Get the node at $path + * + * @param string $path + * @return \OC\Files\Node\Node + * @throws \OC\Files\NotFoundException + */ + public function get($path) { + return $this->root->get($this->getFullPath($path)); + } + + /** + * @param string $path + * @return bool + */ + public function nodeExists($path) { + try { + $this->get($path); + return true; + } catch (NotFoundException $e) { + return false; + } + } + + /** + * @param string $path + * @return Folder + * @throws NotPermittedException + */ + public function newFolder($path) { + if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { + $fullPath = $this->getFullPath($path); + $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); + $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); + $this->root->emit('\OC\Files', 'preCreate', array($nonExisting)); + $this->view->mkdir($fullPath); + $node = new Folder($this->root, $this->view, $fullPath); + $this->root->emit('\OC\Files', 'postWrite', array($node)); + $this->root->emit('\OC\Files', 'postCreate', array($node)); + return $node; + } else { + throw new NotPermittedException(); + } + } + + /** + * @param string $path + * @return File + * @throws NotPermittedException + */ + public function newFile($path) { + if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { + $fullPath = $this->getFullPath($path); + $nonExisting = new NonExistingFile($this->root, $this->view, $fullPath); + $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); + $this->root->emit('\OC\Files', 'preCreate', array($nonExisting)); + $this->view->touch($fullPath); + $node = new File($this->root, $this->view, $fullPath); + $this->root->emit('\OC\Files', 'postWrite', array($node)); + $this->root->emit('\OC\Files', 'postCreate', array($node)); + return $node; + } else { + throw new NotPermittedException(); + } + } + + /** + * search for files with the name matching $query + * + * @param string $query + * @return Node[] + */ + public function search($query) { + return $this->searchCommon('%' . $query . '%', 'search'); + } + + /** + * search for files by mimetype + * + * @param string $mimetype + * @return Node[] + */ + public function searchByMime($mimetype) { + return $this->searchCommon($mimetype, 'searchByMime'); + } + + /** + * @param string $query + * @param string $method + * @return Node[] + */ + private function searchCommon($query, $method) { + $files = array(); + $rootLength = strlen($this->path); + /** + * @var \OC\Files\Storage\Storage $storage + */ + list($storage, $internalPath) = $this->view->resolvePath($this->path); + $internalRootLength = strlen($internalPath); + + $cache = $storage->getCache(''); + + $results = $cache->$method($query); + foreach ($results as $result) { + if ($internalRootLength === 0 or substr($result['path'], 0, $internalRootLength) === $internalPath) { + $result['internalPath'] = $result['path']; + $result['path'] = substr($result['path'], $internalRootLength); + $result['storage'] = $storage; + $files[] = $result; + } + } + + $mounts = $this->root->getMountsIn($this->path); + foreach ($mounts as $mount) { + $storage = $mount->getStorage(); + if ($storage) { + $cache = $storage->getCache(''); + + $relativeMountPoint = substr($mount->getMountPoint(), $rootLength); + $results = $cache->$method($query); + foreach ($results as $result) { + $result['internalPath'] = $result['path']; + $result['path'] = $relativeMountPoint . $result['path']; + $result['storage'] = $storage; + $files[] = $result; + } + } + } + + $result = array(); + foreach ($files as $file) { + $result[] = $this->createNode($this->normalizePath($this->path . '/' . $file['path']), $file); + } + + return $result; + } + + /** + * @param $id + * @return Node[] + */ + public function getById($id) { + $nodes = $this->root->getById($id); + $result = array(); + foreach ($nodes as $node) { + $pathPart = substr($node->getPath(), 0, strlen($this->getPath()) + 1); + if ($this->path === '/' or $pathPart === $this->getPath() . '/') { + $result[] = $node; + } + } + return $result; + } + + public function getFreeSpace() { + return $this->view->free_space($this->path); + } + + /** + * @return bool + */ + public function isCreatable() { + return $this->checkPermissions(\OCP\PERMISSION_CREATE); + } + + public function delete() { + if ($this->checkPermissions(\OCP\PERMISSION_DELETE)) { + $this->sendHooks(array('preDelete')); + $this->view->rmdir($this->path); + $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path); + $this->root->emit('\OC\Files', 'postDelete', array($nonExisting)); + $this->exists = false; + } else { + throw new NotPermittedException(); + } + } + + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function copy($targetPath) { + $targetPath = $this->normalizePath($targetPath); + $parent = $this->root->get(dirname($targetPath)); + if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) { + $nonExisting = new NonExistingFolder($this->root, $this->view, $targetPath); + $this->root->emit('\OC\Files', 'preCopy', array($this, $nonExisting)); + $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); + $this->view->copy($this->path, $targetPath); + $targetNode = $this->root->get($targetPath); + $this->root->emit('\OC\Files', 'postCopy', array($this, $targetNode)); + $this->root->emit('\OC\Files', 'postWrite', array($targetNode)); + return $targetNode; + } else { + throw new NotPermittedException(); + } + } + + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function move($targetPath) { + $targetPath = $this->normalizePath($targetPath); + $parent = $this->root->get(dirname($targetPath)); + if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) { + $nonExisting = new NonExistingFolder($this->root, $this->view, $targetPath); + $this->root->emit('\OC\Files', 'preRename', array($this, $nonExisting)); + $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); + $this->view->rename($this->path, $targetPath); + $targetNode = $this->root->get($targetPath); + $this->root->emit('\OC\Files', 'postRename', array($this, $targetNode)); + $this->root->emit('\OC\Files', 'postWrite', array($targetNode)); + $this->path = $targetPath; + return $targetNode; + } else { + throw new NotPermittedException(); + } + } +} diff --git a/lib/files/node/node.php b/lib/files/node/node.php new file mode 100644 index 00000000000..a71f7875064 --- /dev/null +++ b/lib/files/node/node.php @@ -0,0 +1,247 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Node; + +use OC\Files\Cache\Cache; +use OC\Files\Cache\Scanner; +use OC\Files\NotFoundException; +use OC\Files\NotPermittedException; + +require_once 'files/exceptions.php'; + +class Node { + /** + * @var \OC\Files\View $view + */ + protected $view; + + /** + * @var \OC\Files\Node\Root $root + */ + protected $root; + + /** + * @var string $path + */ + protected $path; + + /** + * @param \OC\Files\View $view + * @param \OC\Files\Node\Root Root $root + * @param string $path + */ + public function __construct($root, $view, $path) { + $this->view = $view; + $this->root = $root; + $this->path = $path; + } + + /** + * @param string[] $hooks + */ + protected function sendHooks($hooks) { + foreach ($hooks as $hook) { + $this->root->emit('\OC\Files', $hook, array($this)); + } + } + + /** + * @param int $permissions + * @return bool + */ + protected function checkPermissions($permissions) { + return ($this->getPermissions() & $permissions) == $permissions; + } + + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function move($targetPath) { + return; + } + + public function delete() { + return; + } + + /** + * @param string $targetPath + * @return \OC\Files\Node\Node + */ + public function copy($targetPath) { + return; + } + + /** + * @param int $mtime + * @throws \OC\Files\NotPermittedException + */ + public function touch($mtime = null) { + if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { + $this->sendHooks(array('preTouch')); + $this->view->touch($this->path, $mtime); + $this->sendHooks(array('postTouch')); + } else { + throw new NotPermittedException(); + } + } + + /** + * @return \OC\Files\Storage\Storage + * @throws \OC\Files\NotFoundException + */ + public function getStorage() { + list($storage,) = $this->view->resolvePath($this->path); + return $storage; + } + + /** + * @return string + */ + public function getPath() { + return $this->path; + } + + /** + * @return string + */ + public function getInternalPath() { + list(, $internalPath) = $this->view->resolvePath($this->path); + return $internalPath; + } + + /** + * @return int + */ + public function getId() { + $info = $this->view->getFileInfo($this->path); + return $info['fileid']; + } + + /** + * @return array + */ + public function stat() { + return $this->view->stat($this->path); + } + + /** + * @return int + */ + public function getMTime() { + return $this->view->filemtime($this->path); + } + + /** + * @return int + */ + public function getSize() { + return $this->view->filesize($this->path); + } + + /** + * @return string + */ + public function getEtag() { + $info = $this->view->getFileInfo($this->path); + return $info['etag']; + } + + /** + * @return int + */ + public function getPermissions() { + $info = $this->view->getFileInfo($this->path); + return $info['permissions']; + } + + /** + * @return bool + */ + public function isReadable() { + return $this->checkPermissions(\OCP\PERMISSION_READ); + } + + /** + * @return bool + */ + public function isUpdateable() { + return $this->checkPermissions(\OCP\PERMISSION_UPDATE); + } + + /** + * @return bool + */ + public function isDeletable() { + return $this->checkPermissions(\OCP\PERMISSION_DELETE); + } + + /** + * @return bool + */ + public function isShareable() { + return $this->checkPermissions(\OCP\PERMISSION_SHARE); + } + + /** + * @return Node + */ + public function getParent() { + return $this->root->get(dirname($this->path)); + } + + /** + * @return string + */ + public function getName() { + return basename($this->path); + } + + /** + * @param string $path + * @return string + */ + protected function normalizePath($path) { + if ($path === '' or $path === '/') { + return '/'; + } + //no windows style slashes + $path = str_replace('\\', '/', $path); + //add leading slash + if ($path[0] !== '/') { + $path = '/' . $path; + } + //remove duplicate slashes + while (strpos($path, '//') !== false) { + $path = str_replace('//', '/', $path); + } + //remove trailing slash + $path = rtrim($path, '/'); + + return $path; + } + + /** + * check if the requested path is valid + * + * @param string $path + * @return bool + */ + public function isValidPath($path) { + if (!$path || $path[0] !== '/') { + $path = '/' . $path; + } + if (strstr($path, '/../') || strrchr($path, '/') === '/..') { + return false; + } + return true; + } +} diff --git a/lib/files/node/nonexistingfile.php b/lib/files/node/nonexistingfile.php new file mode 100644 index 00000000000..6f18450efee --- /dev/null +++ b/lib/files/node/nonexistingfile.php @@ -0,0 +1,89 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Node; + +use OC\Files\NotFoundException; + +class NonExistingFile extends File { + /** + * @param string $newPath + * @throws \OC\Files\NotFoundException + */ + public function rename($newPath) { + throw new NotFoundException(); + } + + public function delete() { + throw new NotFoundException(); + } + + public function copy($newPath) { + throw new NotFoundException(); + } + + public function touch($mtime = null) { + throw new NotFoundException(); + } + + public function getId() { + throw new NotFoundException(); + } + + public function stat() { + throw new NotFoundException(); + } + + public function getMTime() { + throw new NotFoundException(); + } + + public function getSize() { + throw new NotFoundException(); + } + + public function getEtag() { + throw new NotFoundException(); + } + + public function getPermissions() { + throw new NotFoundException(); + } + + public function isReadable() { + throw new NotFoundException(); + } + + public function isUpdateable() { + throw new NotFoundException(); + } + + public function isDeletable() { + throw new NotFoundException(); + } + + public function isShareable() { + throw new NotFoundException(); + } + + public function getContent() { + throw new NotFoundException(); + } + + public function putContent($data) { + throw new NotFoundException(); + } + + public function getMimeType() { + throw new NotFoundException(); + } + + public function fopen($mode) { + throw new NotFoundException(); + } +} diff --git a/lib/files/node/nonexistingfolder.php b/lib/files/node/nonexistingfolder.php new file mode 100644 index 00000000000..0249a026245 --- /dev/null +++ b/lib/files/node/nonexistingfolder.php @@ -0,0 +1,113 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Node; + +use OC\Files\NotFoundException; + +class NonExistingFolder extends Folder { + /** + * @param string $newPath + * @throws \OC\Files\NotFoundException + */ + public function rename($newPath) { + throw new NotFoundException(); + } + + public function delete() { + throw new NotFoundException(); + } + + public function copy($newPath) { + throw new NotFoundException(); + } + + public function touch($mtime = null) { + throw new NotFoundException(); + } + + public function getId() { + throw new NotFoundException(); + } + + public function stat() { + throw new NotFoundException(); + } + + public function getMTime() { + throw new NotFoundException(); + } + + public function getSize() { + throw new NotFoundException(); + } + + public function getEtag() { + throw new NotFoundException(); + } + + public function getPermissions() { + throw new NotFoundException(); + } + + public function isReadable() { + throw new NotFoundException(); + } + + public function isUpdateable() { + throw new NotFoundException(); + } + + public function isDeletable() { + throw new NotFoundException(); + } + + public function isShareable() { + throw new NotFoundException(); + } + + public function get($path) { + throw new NotFoundException(); + } + + public function getDirectoryListing() { + throw new NotFoundException(); + } + + public function nodeExists($path) { + return false; + } + + public function newFolder($path) { + throw new NotFoundException(); + } + + public function newFile($path) { + throw new NotFoundException(); + } + + public function search($pattern) { + throw new NotFoundException(); + } + + public function searchByMime($mime) { + throw new NotFoundException(); + } + + public function getById($id) { + throw new NotFoundException(); + } + + public function getFreeSpace() { + throw new NotFoundException(); + } + + public function isCreatable() { + throw new NotFoundException(); + } +} diff --git a/lib/files/node/root.php b/lib/files/node/root.php new file mode 100644 index 00000000000..f88d8c294c7 --- /dev/null +++ b/lib/files/node/root.php @@ -0,0 +1,337 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Node; + +use OC\Files\Cache\Cache; +use OC\Files\Cache\Scanner; +use OC\Files\Mount\Manager; +use OC\Files\Mount\Mount; +use OC\Files\NotFoundException; +use OC\Files\NotPermittedException; +use OC\Hooks\Emitter; +use OC\Hooks\PublicEmitter; + +/** + * Class Root + * + * Hooks available in scope \OC\Files + * - preWrite(\OC\Files\Node\Node $node) + * - postWrite(\OC\Files\Node\Node $node) + * - preCreate(\OC\Files\Node\Node $node) + * - postCreate(\OC\Files\Node\Node $node) + * - preDelete(\OC\Files\Node\Node $node) + * - postDelete(\OC\Files\Node\Node $node) + * - preTouch(\OC\Files\Node\Node $node, int $mtime) + * - postTouch(\OC\Files\Node\Node $node) + * - preCopy(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) + * - postCopy(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) + * - preRename(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) + * - postRename(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) + * + * @package OC\Files\Node + */ +class Root extends Folder implements Emitter { + + /** + * @var \OC\Files\Mount\Manager $mountManager + */ + private $mountManager; + + /** + * @var \OC\Hooks\PublicEmitter + */ + private $emitter; + + /** + * @var \OC\User\User $user + */ + private $user; + + /** + * @param \OC\Files\Mount\Manager $manager + * @param \OC\Files\View $view + * @param \OC\User\User $user + */ + public function __construct($manager, $view, $user) { + parent::__construct($this, $view, ''); + $this->mountManager = $manager; + $this->user = $user; + $this->emitter = new PublicEmitter(); + } + + /** + * Get the user for which the filesystem is setup + * + * @return \OC\User\User + */ + public function getUser() { + return $this->user; + } + + /** + * @param string $scope + * @param string $method + * @param callable $callback + */ + public function listen($scope, $method, $callback) { + $this->emitter->listen($scope, $method, $callback); + } + + /** + * @param string $scope optional + * @param string $method optional + * @param callable $callback optional + */ + public function removeListener($scope = null, $method = null, $callback = null) { + $this->emitter->removeListener($scope, $method, $callback); + } + + /** + * @param string $scope + * @param string $method + * @param array $arguments + */ + public function emit($scope, $method, $arguments = array()) { + $this->emitter->emit($scope, $method, $arguments); + } + + /** + * @param \OC\Files\Storage\Storage $storage + * @param string $mountPoint + * @param array $arguments + */ + public function mount($storage, $mountPoint, $arguments = array()) { + $mount = new Mount($storage, $mountPoint, $arguments); + $this->mountManager->addMount($mount); + } + + /** + * @param string $mountPoint + * @return \OC\Files\Mount\Mount + */ + public function getMount($mountPoint) { + return $this->mountManager->find($mountPoint); + } + + /** + * @param string $mountPoint + * @return \OC\Files\Mount\Mount[] + */ + public function getMountsIn($mountPoint) { + return $this->mountManager->findIn($mountPoint); + } + + /** + * @param string $storageId + * @return \OC\Files\Mount\Mount[] + */ + public function getMountByStorageId($storageId) { + return $this->mountManager->findByStorageId($storageId); + } + + /** + * @param int $numericId + * @return Mount[] + */ + public function getMountByNumericStorageId($numericId) { + return $this->mountManager->findByNumericId($numericId); + } + + /** + * @param \OC\Files\Mount\Mount $mount + */ + public function unMount($mount) { + $this->mountManager->remove($mount); + } + + /** + * @param string $path + * @throws \OC\Files\NotFoundException + * @throws \OC\Files\NotPermittedException + * @return Node + */ + public function get($path) { + $path = $this->normalizePath($path); + if ($this->isValidPath($path)) { + $fullPath = $this->getFullPath($path); + if ($this->view->file_exists($fullPath)) { + return $this->createNode($fullPath); + } else { + throw new NotFoundException(); + } + } else { + throw new NotPermittedException(); + } + } + + /** + * search file by id + * + * An array is returned because in the case where a single storage is mounted in different places the same file + * can exist in different places + * + * @param int $id + * @throws \OC\Files\NotFoundException + * @return Node[] + */ + public function getById($id) { + $result = Cache::getById($id); + if (is_null($result)) { + throw new NotFoundException(); + } else { + list($storageId, $internalPath) = $result; + $nodes = array(); + $mounts = $this->mountManager->findByStorageId($storageId); + foreach ($mounts as $mount) { + $nodes[] = $this->get($mount->getMountPoint() . $internalPath); + } + return $nodes; + } + + } + + //most operations cant be done on the root + + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function rename($targetPath) { + throw new NotPermittedException(); + } + + public function delete() { + throw new NotPermittedException(); + } + + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function copy($targetPath) { + throw new NotPermittedException(); + } + + /** + * @param int $mtime + * @throws \OC\Files\NotPermittedException + */ + public function touch($mtime = null) { + throw new NotPermittedException(); + } + + /** + * @return \OC\Files\Storage\Storage + * @throws \OC\Files\NotFoundException + */ + public function getStorage() { + throw new NotFoundException(); + } + + /** + * @return string + */ + public function getPath() { + return '/'; + } + + /** + * @return string + */ + public function getInternalPath() { + return ''; + } + + /** + * @return int + */ + public function getId() { + return null; + } + + /** + * @return array + */ + public function stat() { + return null; + } + + /** + * @return int + */ + public function getMTime() { + return null; + } + + /** + * @return int + */ + public function getSize() { + return null; + } + + /** + * @return string + */ + public function getEtag() { + return null; + } + + /** + * @return int + */ + public function getPermissions() { + return \OCP\PERMISSION_CREATE; + } + + /** + * @return bool + */ + public function isReadable() { + return false; + } + + /** + * @return bool + */ + public function isUpdateable() { + return false; + } + + /** + * @return bool + */ + public function isDeletable() { + return false; + } + + /** + * @return bool + */ + public function isShareable() { + return false; + } + + /** + * @return Node + * @throws \OC\Files\NotFoundException + */ + public function getParent() { + throw new NotFoundException(); + } + + /** + * @return string + */ + public function getName() { + return ''; + } +} -- cgit v1.2.3 From 1cfd03771f3ba8a91b5600cf71c6f455d288bbe0 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 6 Sep 2013 20:20:17 +0200 Subject: use === --- lib/files/node/node.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/files/node') diff --git a/lib/files/node/node.php b/lib/files/node/node.php index a71f7875064..a1db042c25c 100644 --- a/lib/files/node/node.php +++ b/lib/files/node/node.php @@ -56,7 +56,7 @@ class Node { * @return bool */ protected function checkPermissions($permissions) { - return ($this->getPermissions() & $permissions) == $permissions; + return ($this->getPermissions() & $permissions) === $permissions; } /** -- cgit v1.2.3 From 0131a3202597fe2cfefbb72e1a20fd266d48451a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 6 Sep 2013 20:38:59 +0200 Subject: extract interfaces from fileapi for public namespace --- lib/files/node/file.php | 2 +- lib/files/node/folder.php | 2 +- lib/files/node/node.php | 2 +- lib/public/files/node/file.php | 44 ++++++++++++++++ lib/public/files/node/folder.php | 104 +++++++++++++++++++++++++++++++++++++ lib/public/files/node/node.php | 108 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 lib/public/files/node/file.php create mode 100644 lib/public/files/node/folder.php create mode 100644 lib/public/files/node/node.php (limited to 'lib/files/node') diff --git a/lib/files/node/file.php b/lib/files/node/file.php index 0ad5d68ec66..f13b474aa6c 100644 --- a/lib/files/node/file.php +++ b/lib/files/node/file.php @@ -10,7 +10,7 @@ namespace OC\Files\Node; use OC\Files\NotPermittedException; -class File extends Node { +class File extends Node implements \OCP\Files\Node\File { /** * @return string * @throws \OC\Files\NotPermittedException diff --git a/lib/files/node/folder.php b/lib/files/node/folder.php index f710ae5ae9a..daf75d7c23e 100644 --- a/lib/files/node/folder.php +++ b/lib/files/node/folder.php @@ -13,7 +13,7 @@ use OC\Files\Cache\Scanner; use OC\Files\NotFoundException; use OC\Files\NotPermittedException; -class Folder extends Node { +class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param string $path path relative to the folder * @return string diff --git a/lib/files/node/node.php b/lib/files/node/node.php index a1db042c25c..5ee9f23161f 100644 --- a/lib/files/node/node.php +++ b/lib/files/node/node.php @@ -15,7 +15,7 @@ use OC\Files\NotPermittedException; require_once 'files/exceptions.php'; -class Node { +class Node implements \OCP\Files\Node\Node { /** * @var \OC\Files\View $view */ diff --git a/lib/public/files/node/file.php b/lib/public/files/node/file.php new file mode 100644 index 00000000000..193663f60b8 --- /dev/null +++ b/lib/public/files/node/file.php @@ -0,0 +1,44 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files\Node; + +use OC\Files\NotPermittedException; + +interface File extends Node { + /** + * @return string + * @throws \OC\Files\NotPermittedException + */ + public function getContent(); + + /** + * @param string $data + * @throws \OC\Files\NotPermittedException + */ + public function putContent($data); + + /** + * @return string + */ + public function getMimeType(); + + /** + * @param string $mode + * @return resource + * @throws \OC\Files\NotPermittedException + */ + public function fopen($mode); + + /** + * @param string $type + * @param bool $raw + * @return string + */ + public function hash($type, $raw = false); +} diff --git a/lib/public/files/node/folder.php b/lib/public/files/node/folder.php new file mode 100644 index 00000000000..7b3ae80f0d7 --- /dev/null +++ b/lib/public/files/node/folder.php @@ -0,0 +1,104 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files\Node; + +use OC\Files\Cache\Cache; +use OC\Files\Cache\Scanner; +use OC\Files\NotFoundException; +use OC\Files\NotPermittedException; + +interface Folder extends Node { + /** + * @param string $path path relative to the folder + * @return string + * @throws \OC\Files\NotPermittedException + */ + public function getFullPath($path); + + /** + * @param string $path + * @throws \OC\Files\NotFoundException + * @return string + */ + public function getRelativePath($path); + + /** + * check if a node is a (grand-)child of the folder + * + * @param \OC\Files\Node\Node $node + * @return bool + */ + public function isSubNode($node); + + /** + * get the content of this directory + * + * @throws \OC\Files\NotFoundException + * @return Node[] + */ + public function getDirectoryListing(); + + /** + * Get the node at $path + * + * @param string $path + * @return \OC\Files\Node\Node + * @throws \OC\Files\NotFoundException + */ + public function get($path); + + /** + * @param string $path + * @return bool + */ + public function nodeExists($path); + + /** + * @param string $path + * @return Folder + * @throws NotPermittedException + */ + public function newFolder($path); + + /** + * @param string $path + * @return File + * @throws NotPermittedException + */ + public function newFile($path); + + /** + * search for files with the name matching $query + * + * @param string $query + * @return Node[] + */ + public function search($query); + + /** + * search for files by mimetype + * + * @param string $mimetype + * @return Node[] + */ + public function searchByMime($mimetype); + + /** + * @param $id + * @return Node[] + */ + public function getById($id); + + public function getFreeSpace(); + + /** + * @return bool + */ + public function isCreatable(); +} diff --git a/lib/public/files/node/node.php b/lib/public/files/node/node.php new file mode 100644 index 00000000000..085e880e375 --- /dev/null +++ b/lib/public/files/node/node.php @@ -0,0 +1,108 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files\Node; + +interface Node { + /** + * @param string $targetPath + * @throws \OC\Files\NotPermittedException + * @return \OC\Files\Node\Node + */ + public function move($targetPath); + + public function delete(); + + /** + * @param string $targetPath + * @return \OC\Files\Node\Node + */ + public function copy($targetPath); + + /** + * @param int $mtime + * @throws \OC\Files\NotPermittedException + */ + public function touch($mtime = null); + + /** + * @return \OC\Files\Storage\Storage + * @throws \OC\Files\NotFoundException + */ + public function getStorage(); + + /** + * @return string + */ + public function getPath(); + + /** + * @return string + */ + public function getInternalPath(); + + /** + * @return int + */ + public function getId(); + + /** + * @return array + */ + public function stat(); + + /** + * @return int + */ + public function getMTime(); + + /** + * @return int + */ + public function getSize(); + + /** + * @return string + */ + public function getEtag(); + + /** + * @return int + */ + public function getPermissions(); + + /** + * @return bool + */ + public function isReadable(); + + /** + * @return bool + */ + public function isUpdateable(); + + /** + * @return bool + */ + public function isDeletable(); + + /** + * @return bool + */ + public function isShareable(); + + /** + * @return Node + */ + public function getParent(); + + /** + * @return string + */ + public function getName(); +} -- cgit v1.2.3 From e271a55783dafd605791d02ca718b463fa19d58d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 10 Sep 2013 19:44:23 +0200 Subject: move filesystem expceptions to global namespace --- lib/files/node/file.php | 14 ++++----- lib/files/node/folder.php | 32 ++++++++++---------- lib/files/node/node.php | 14 ++++----- lib/files/node/nonexistingfile.php | 4 +-- lib/files/node/nonexistingfolder.php | 4 +-- lib/files/node/root.php | 44 ++++++++++++++-------------- lib/public/files/alreadyexistsexception.php | 11 +++++++ lib/public/files/notenoughspaceexception.php | 11 +++++++ lib/public/files/notfoundexception.php | 11 +++++++ lib/public/files/notpermittedexception.php | 11 +++++++ 10 files changed, 99 insertions(+), 57 deletions(-) create mode 100644 lib/public/files/alreadyexistsexception.php create mode 100644 lib/public/files/notenoughspaceexception.php create mode 100644 lib/public/files/notfoundexception.php create mode 100644 lib/public/files/notpermittedexception.php (limited to 'lib/files/node') diff --git a/lib/files/node/file.php b/lib/files/node/file.php index f13b474aa6c..75d5e0166b6 100644 --- a/lib/files/node/file.php +++ b/lib/files/node/file.php @@ -8,12 +8,12 @@ namespace OC\Files\Node; -use OC\Files\NotPermittedException; +use OCP\Files\NotPermittedException; -class File extends Node implements \OCP\Files\Node\File { +class File extends Node implements \OCP\Files\File { /** * @return string - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException */ public function getContent() { if ($this->checkPermissions(\OCP\PERMISSION_READ)) { @@ -28,7 +28,7 @@ class File extends Node implements \OCP\Files\Node\File { /** * @param string $data - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException */ public function putContent($data) { if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { @@ -50,7 +50,7 @@ class File extends Node implements \OCP\Files\Node\File { /** * @param string $mode * @return resource - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException */ public function fopen($mode) { $preHooks = array(); @@ -101,7 +101,7 @@ class File extends Node implements \OCP\Files\Node\File { /** * @param string $targetPath - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node */ public function copy($targetPath) { @@ -123,7 +123,7 @@ class File extends Node implements \OCP\Files\Node\File { /** * @param string $targetPath - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node */ public function move($targetPath) { diff --git a/lib/files/node/folder.php b/lib/files/node/folder.php index daf75d7c23e..923f53821b2 100644 --- a/lib/files/node/folder.php +++ b/lib/files/node/folder.php @@ -10,14 +10,14 @@ namespace OC\Files\Node; use OC\Files\Cache\Cache; use OC\Files\Cache\Scanner; -use OC\Files\NotFoundException; -use OC\Files\NotPermittedException; +use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; -class Folder extends Node implements \OCP\Files\Node\Folder { +class Folder extends Node implements \OCP\Files\Folder { /** * @param string $path path relative to the folder * @return string - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException */ public function getFullPath($path) { if (!$this->isValidPath($path)) { @@ -28,7 +28,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param string $path - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException * @return string */ public function getRelativePath($path) { @@ -60,7 +60,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * get the content of this directory * - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException * @return Node[] */ public function getDirectoryListing() { @@ -164,7 +164,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { * * @param string $path * @return \OC\Files\Node\Node - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException */ public function get($path) { return $this->root->get($this->getFullPath($path)); @@ -185,8 +185,8 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param string $path - * @return Folder - * @throws NotPermittedException + * @return \OC\Files\Node\Folder + * @throws \OCP\Files\NotPermittedException */ public function newFolder($path) { if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { @@ -206,8 +206,8 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param string $path - * @return File - * @throws NotPermittedException + * @return \OC\Files\Node\File + * @throws \OCP\Files\NotPermittedException */ public function newFile($path) { if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { @@ -229,7 +229,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { * search for files with the name matching $query * * @param string $query - * @return Node[] + * @return \OC\Files\Node\Node[] */ public function search($query) { return $this->searchCommon('%' . $query . '%', 'search'); @@ -248,7 +248,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param string $query * @param string $method - * @return Node[] + * @return \OC\Files\Node\Node[] */ private function searchCommon($query, $method) { $files = array(); @@ -298,7 +298,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param $id - * @return Node[] + * @return \OC\Files\Node\Node[] */ public function getById($id) { $nodes = $this->root->getById($id); @@ -337,7 +337,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param string $targetPath - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node */ public function copy($targetPath) { @@ -359,7 +359,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder { /** * @param string $targetPath - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node */ public function move($targetPath) { diff --git a/lib/files/node/node.php b/lib/files/node/node.php index 5ee9f23161f..063e2424a64 100644 --- a/lib/files/node/node.php +++ b/lib/files/node/node.php @@ -10,12 +10,10 @@ namespace OC\Files\Node; use OC\Files\Cache\Cache; use OC\Files\Cache\Scanner; -use OC\Files\NotFoundException; -use OC\Files\NotPermittedException; +use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; -require_once 'files/exceptions.php'; - -class Node implements \OCP\Files\Node\Node { +class Node implements \OCP\Files\Node { /** * @var \OC\Files\View $view */ @@ -61,7 +59,7 @@ class Node implements \OCP\Files\Node\Node { /** * @param string $targetPath - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node */ public function move($targetPath) { @@ -82,7 +80,7 @@ class Node implements \OCP\Files\Node\Node { /** * @param int $mtime - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException */ public function touch($mtime = null) { if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { @@ -96,7 +94,7 @@ class Node implements \OCP\Files\Node\Node { /** * @return \OC\Files\Storage\Storage - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException */ public function getStorage() { list($storage,) = $this->view->resolvePath($this->path); diff --git a/lib/files/node/nonexistingfile.php b/lib/files/node/nonexistingfile.php index 6f18450efee..d45076f7fee 100644 --- a/lib/files/node/nonexistingfile.php +++ b/lib/files/node/nonexistingfile.php @@ -8,12 +8,12 @@ namespace OC\Files\Node; -use OC\Files\NotFoundException; +use OCP\Files\NotFoundException; class NonExistingFile extends File { /** * @param string $newPath - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException */ public function rename($newPath) { throw new NotFoundException(); diff --git a/lib/files/node/nonexistingfolder.php b/lib/files/node/nonexistingfolder.php index 0249a026245..0346cbf1e21 100644 --- a/lib/files/node/nonexistingfolder.php +++ b/lib/files/node/nonexistingfolder.php @@ -8,12 +8,12 @@ namespace OC\Files\Node; -use OC\Files\NotFoundException; +use OCP\Files\NotFoundException; class NonExistingFolder extends Folder { /** * @param string $newPath - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException */ public function rename($newPath) { throw new NotFoundException(); diff --git a/lib/files/node/root.php b/lib/files/node/root.php index f88d8c294c7..e3d58476e9c 100644 --- a/lib/files/node/root.php +++ b/lib/files/node/root.php @@ -12,8 +12,8 @@ use OC\Files\Cache\Cache; use OC\Files\Cache\Scanner; use OC\Files\Mount\Manager; use OC\Files\Mount\Mount; -use OC\Files\NotFoundException; -use OC\Files\NotPermittedException; +use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OC\Hooks\Emitter; use OC\Hooks\PublicEmitter; @@ -21,18 +21,18 @@ use OC\Hooks\PublicEmitter; * Class Root * * Hooks available in scope \OC\Files - * - preWrite(\OC\Files\Node\Node $node) - * - postWrite(\OC\Files\Node\Node $node) - * - preCreate(\OC\Files\Node\Node $node) - * - postCreate(\OC\Files\Node\Node $node) - * - preDelete(\OC\Files\Node\Node $node) - * - postDelete(\OC\Files\Node\Node $node) - * - preTouch(\OC\Files\Node\Node $node, int $mtime) - * - postTouch(\OC\Files\Node\Node $node) - * - preCopy(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) - * - postCopy(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) - * - preRename(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) - * - postRename(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target) + * - preWrite(\OCP\Files\Node $node) + * - postWrite(\OCP\Files\Node $node) + * - preCreate(\OCP\Files\Node $node) + * - postCreate(\OCP\Files\Node $node) + * - preDelete(\OCP\Files\Node $node) + * - postDelete(\OCP\Files\Node $node) + * - preTouch(\OC\FilesP\Node $node, int $mtime) + * - postTouch(\OCP\Files\Node $node) + * - preCopy(\OCP\Files\Node $source, \OCP\Files\Node $target) + * - postCopy(\OCP\Files\Node $source, \OCP\Files\Node $target) + * - preRename(\OCP\Files\Node $source, \OCP\Files\Node $target) + * - postRename(\OCP\Files\Node $source, \OCP\Files\Node $target) * * @package OC\Files\Node */ @@ -152,8 +152,8 @@ class Root extends Folder implements Emitter { /** * @param string $path - * @throws \OC\Files\NotFoundException - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotFoundException + * @throws \OCP\Files\NotPermittedException * @return Node */ public function get($path) { @@ -177,7 +177,7 @@ class Root extends Folder implements Emitter { * can exist in different places * * @param int $id - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException * @return Node[] */ public function getById($id) { @@ -200,7 +200,7 @@ class Root extends Folder implements Emitter { /** * @param string $targetPath - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node */ public function rename($targetPath) { @@ -213,7 +213,7 @@ class Root extends Folder implements Emitter { /** * @param string $targetPath - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node */ public function copy($targetPath) { @@ -222,7 +222,7 @@ class Root extends Folder implements Emitter { /** * @param int $mtime - * @throws \OC\Files\NotPermittedException + * @throws \OCP\Files\NotPermittedException */ public function touch($mtime = null) { throw new NotPermittedException(); @@ -230,7 +230,7 @@ class Root extends Folder implements Emitter { /** * @return \OC\Files\Storage\Storage - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException */ public function getStorage() { throw new NotFoundException(); @@ -322,7 +322,7 @@ class Root extends Folder implements Emitter { /** * @return Node - * @throws \OC\Files\NotFoundException + * @throws \OCP\Files\NotFoundException */ public function getParent() { throw new NotFoundException(); diff --git a/lib/public/files/alreadyexistsexception.php b/lib/public/files/alreadyexistsexception.php new file mode 100644 index 00000000000..32947c7a5c3 --- /dev/null +++ b/lib/public/files/alreadyexistsexception.php @@ -0,0 +1,11 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files; + +class AlreadyExistsException extends \Exception {} diff --git a/lib/public/files/notenoughspaceexception.php b/lib/public/files/notenoughspaceexception.php new file mode 100644 index 00000000000..e51806666ad --- /dev/null +++ b/lib/public/files/notenoughspaceexception.php @@ -0,0 +1,11 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files; + +class NotEnoughSpaceException extends \Exception {} diff --git a/lib/public/files/notfoundexception.php b/lib/public/files/notfoundexception.php new file mode 100644 index 00000000000..1ff426a40c6 --- /dev/null +++ b/lib/public/files/notfoundexception.php @@ -0,0 +1,11 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files; + +class NotFoundException extends \Exception {} diff --git a/lib/public/files/notpermittedexception.php b/lib/public/files/notpermittedexception.php new file mode 100644 index 00000000000..0509de7e829 --- /dev/null +++ b/lib/public/files/notpermittedexception.php @@ -0,0 +1,11 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files; + +class NotPermittedException extends \Exception {} -- cgit v1.2.3