Blame view
sources/lib/private/files/node/root.php
5.93 KB
|
31b7f2792
|
1 2 3 4 5 6 7 8 9 10 11 |
<?php /** * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> * 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; |
|
31b7f2792
|
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
use OC\Files\Mount\Manager;
use OC\Files\Mount\Mount;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OC\Hooks\Emitter;
use OC\Hooks\PublicEmitter;
/**
* Class Root
*
* Hooks available in scope \OC\Files
* - 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
*/
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
|
|
6d9380f96
|
97 |
* @param Node[] $arguments |
|
31b7f2792
|
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
*/
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 \OCP\Files\NotFoundException
* @throws \OCP\Files\NotPermittedException
|
|
6d9380f96
|
156 |
* @return string |
|
31b7f2792
|
157 158 159 160 161 162 163 164 |
*/
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 {
|
|
f7d878ff1
|
165 |
throw new NotFoundException($path); |
|
31b7f2792
|
166 167 168 169 170 |
}
} else {
throw new NotPermittedException();
}
}
|
|
31b7f2792
|
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
//most operations cant be done on the root
/**
* @param string $targetPath
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function rename($targetPath) {
throw new NotPermittedException();
}
public function delete() {
throw new NotPermittedException();
}
/**
* @param string $targetPath
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function copy($targetPath) {
throw new NotPermittedException();
}
/**
* @param int $mtime
* @throws \OCP\Files\NotPermittedException
*/
public function touch($mtime = null) {
throw new NotPermittedException();
}
/**
* @return \OC\Files\Storage\Storage
* @throws \OCP\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 \OCP\Files\NotFoundException
*/
public function getParent() {
throw new NotFoundException();
}
/**
* @return string
*/
public function getName() {
return '';
}
}
|