1
0

LazyRoot.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Robin Appelman <robin@icewind.nl>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OC\Files\Node;
  24. use OCP\Files\IRootFolder;
  25. /**
  26. * Class LazyRoot
  27. *
  28. * This is a lazy wrapper around the root. So only
  29. * once it is needed this will get initialized.
  30. *
  31. * @package OC\Files\Node
  32. */
  33. class LazyRoot implements IRootFolder {
  34. /** @var \Closure */
  35. private $rootFolderClosure;
  36. /** @var IRootFolder */
  37. private $rootFolder;
  38. /**
  39. * LazyRoot constructor.
  40. *
  41. * @param \Closure $rootFolderClosure
  42. */
  43. public function __construct(\Closure $rootFolderClosure) {
  44. $this->rootFolderClosure = $rootFolderClosure;
  45. }
  46. /**
  47. * Magic method to first get the real rootFolder and then
  48. * call $method with $args on it
  49. *
  50. * @param $method
  51. * @param $args
  52. * @return mixed
  53. */
  54. public function __call($method, $args) {
  55. if ($this->rootFolder === null) {
  56. $this->rootFolder = call_user_func($this->rootFolderClosure);
  57. }
  58. return call_user_func_array([$this->rootFolder, $method], $args);
  59. }
  60. /**
  61. * @inheritDoc
  62. */
  63. public function getUser() {
  64. return $this->__call(__FUNCTION__, func_get_args());
  65. }
  66. /**
  67. * @inheritDoc
  68. */
  69. public function listen($scope, $method, callable $callback) {
  70. $this->__call(__FUNCTION__, func_get_args());
  71. }
  72. /**
  73. * @inheritDoc
  74. */
  75. public function removeListener($scope = null, $method = null, callable $callback = null) {
  76. $this->__call(__FUNCTION__, func_get_args());
  77. }
  78. /**
  79. * @inheritDoc
  80. */
  81. public function emit($scope, $method, $arguments = array()) {
  82. $this->__call(__FUNCTION__, func_get_args());
  83. }
  84. /**
  85. * @inheritDoc
  86. */
  87. public function mount($storage, $mountPoint, $arguments = array()) {
  88. $this->__call(__FUNCTION__, func_get_args());
  89. }
  90. /**
  91. * @inheritDoc
  92. */
  93. public function getMount($mountPoint) {
  94. return $this->__call(__FUNCTION__, func_get_args());
  95. }
  96. /**
  97. * @inheritDoc
  98. */
  99. public function getMountsIn($mountPoint) {
  100. return $this->__call(__FUNCTION__, func_get_args());
  101. }
  102. /**
  103. * @inheritDoc
  104. */
  105. public function getMountByStorageId($storageId) {
  106. return $this->__call(__FUNCTION__, func_get_args());
  107. }
  108. /**
  109. * @inheritDoc
  110. */
  111. public function getMountByNumericStorageId($numericId) {
  112. return $this->__call(__FUNCTION__, func_get_args());
  113. }
  114. /**
  115. * @inheritDoc
  116. */
  117. public function unMount($mount) {
  118. $this->__call(__FUNCTION__, func_get_args());
  119. }
  120. /**
  121. * @inheritDoc
  122. */
  123. public function get($path) {
  124. return $this->__call(__FUNCTION__, func_get_args());
  125. }
  126. /**
  127. * @inheritDoc
  128. */
  129. public function rename($targetPath) {
  130. return $this->__call(__FUNCTION__, func_get_args());
  131. }
  132. /**
  133. * @inheritDoc
  134. */
  135. public function delete() {
  136. return $this->__call(__FUNCTION__, func_get_args());
  137. }
  138. /**
  139. * @inheritDoc
  140. */
  141. public function copy($targetPath) {
  142. return $this->__call(__FUNCTION__, func_get_args());
  143. }
  144. /**
  145. * @inheritDoc
  146. */
  147. public function touch($mtime = null) {
  148. $this->__call(__FUNCTION__, func_get_args());
  149. }
  150. /**
  151. * @inheritDoc
  152. */
  153. public function getStorage() {
  154. return $this->__call(__FUNCTION__, func_get_args());
  155. }
  156. /**
  157. * @inheritDoc
  158. */
  159. public function getPath() {
  160. return $this->__call(__FUNCTION__, func_get_args());
  161. }
  162. /**
  163. * @inheritDoc
  164. */
  165. public function getInternalPath() {
  166. return $this->__call(__FUNCTION__, func_get_args());
  167. }
  168. /**
  169. * @inheritDoc
  170. */
  171. public function getId() {
  172. return $this->__call(__FUNCTION__, func_get_args());
  173. }
  174. /**
  175. * @inheritDoc
  176. */
  177. public function stat() {
  178. return $this->__call(__FUNCTION__, func_get_args());
  179. }
  180. /**
  181. * @inheritDoc
  182. */
  183. public function getMTime() {
  184. return $this->__call(__FUNCTION__, func_get_args());
  185. }
  186. /**
  187. * @inheritDoc
  188. */
  189. public function getSize() {
  190. return $this->__call(__FUNCTION__, func_get_args());
  191. }
  192. /**
  193. * @inheritDoc
  194. */
  195. public function getEtag() {
  196. return $this->__call(__FUNCTION__, func_get_args());
  197. }
  198. /**
  199. * @inheritDoc
  200. */
  201. public function getPermissions() {
  202. return $this->__call(__FUNCTION__, func_get_args());
  203. }
  204. /**
  205. * @inheritDoc
  206. */
  207. public function isReadable() {
  208. return $this->__call(__FUNCTION__, func_get_args());
  209. }
  210. /**
  211. * @inheritDoc
  212. */
  213. public function isUpdateable() {
  214. return $this->__call(__FUNCTION__, func_get_args());
  215. }
  216. /**
  217. * @inheritDoc
  218. */
  219. public function isDeletable() {
  220. return $this->__call(__FUNCTION__, func_get_args());
  221. }
  222. /**
  223. * @inheritDoc
  224. */
  225. public function isShareable() {
  226. return $this->__call(__FUNCTION__, func_get_args());
  227. }
  228. /**
  229. * @inheritDoc
  230. */
  231. public function getParent() {
  232. return $this->__call(__FUNCTION__, func_get_args());
  233. }
  234. /**
  235. * @inheritDoc
  236. */
  237. public function getName() {
  238. return $this->__call(__FUNCTION__, func_get_args());
  239. }
  240. /**
  241. * @inheritDoc
  242. */
  243. public function getUserFolder($userId) {
  244. return $this->__call(__FUNCTION__, func_get_args());
  245. }
  246. /**
  247. * @inheritDoc
  248. */
  249. public function getMimetype() {
  250. return $this->__call(__FUNCTION__, func_get_args());
  251. }
  252. /**
  253. * @inheritDoc
  254. */
  255. public function getMimePart() {
  256. return $this->__call(__FUNCTION__, func_get_args());
  257. }
  258. /**
  259. * @inheritDoc
  260. */
  261. public function isEncrypted() {
  262. return $this->__call(__FUNCTION__, func_get_args());
  263. }
  264. /**
  265. * @inheritDoc
  266. */
  267. public function getType() {
  268. return $this->__call(__FUNCTION__, func_get_args());
  269. }
  270. /**
  271. * @inheritDoc
  272. */
  273. public function isShared() {
  274. return $this->__call(__FUNCTION__, func_get_args());
  275. }
  276. /**
  277. * @inheritDoc
  278. */
  279. public function isMounted() {
  280. return $this->__call(__FUNCTION__, func_get_args());
  281. }
  282. /**
  283. * @inheritDoc
  284. */
  285. public function getMountPoint() {
  286. return $this->__call(__FUNCTION__, func_get_args());
  287. }
  288. /**
  289. * @inheritDoc
  290. */
  291. public function getOwner() {
  292. return $this->__call(__FUNCTION__, func_get_args());
  293. }
  294. /**
  295. * @inheritDoc
  296. */
  297. public function getChecksum() {
  298. return $this->__call(__FUNCTION__, func_get_args());
  299. }
  300. public function getExtension(): string {
  301. return $this->__call(__FUNCTION__, func_get_args());
  302. }
  303. /**
  304. * @inheritDoc
  305. */
  306. public function getFullPath($path) {
  307. return $this->__call(__FUNCTION__, func_get_args());
  308. }
  309. /**
  310. * @inheritDoc
  311. */
  312. public function getRelativePath($path) {
  313. return $this->__call(__FUNCTION__, func_get_args());
  314. }
  315. /**
  316. * @inheritDoc
  317. */
  318. public function isSubNode($node) {
  319. return $this->__call(__FUNCTION__, func_get_args());
  320. }
  321. /**
  322. * @inheritDoc
  323. */
  324. public function getDirectoryListing() {
  325. return $this->__call(__FUNCTION__, func_get_args());
  326. }
  327. /**
  328. * @inheritDoc
  329. */
  330. public function nodeExists($path) {
  331. return $this->__call(__FUNCTION__, func_get_args());
  332. }
  333. /**
  334. * @inheritDoc
  335. */
  336. public function newFolder($path) {
  337. return $this->__call(__FUNCTION__, func_get_args());
  338. }
  339. /**
  340. * @inheritDoc
  341. */
  342. public function newFile($path) {
  343. return $this->__call(__FUNCTION__, func_get_args());
  344. }
  345. /**
  346. * @inheritDoc
  347. */
  348. public function search($query) {
  349. return $this->__call(__FUNCTION__, func_get_args());
  350. }
  351. /**
  352. * @inheritDoc
  353. */
  354. public function searchByMime($mimetype) {
  355. return $this->__call(__FUNCTION__, func_get_args());
  356. }
  357. /**
  358. * @inheritDoc
  359. */
  360. public function searchByTag($tag, $userId) {
  361. return $this->__call(__FUNCTION__, func_get_args());
  362. }
  363. /**
  364. * @inheritDoc
  365. */
  366. public function getById($id) {
  367. return $this->__call(__FUNCTION__, func_get_args());
  368. }
  369. /**
  370. * @inheritDoc
  371. */
  372. public function getFreeSpace() {
  373. return $this->__call(__FUNCTION__, func_get_args());
  374. }
  375. /**
  376. * @inheritDoc
  377. */
  378. public function isCreatable() {
  379. return $this->__call(__FUNCTION__, func_get_args());
  380. }
  381. /**
  382. * @inheritDoc
  383. */
  384. public function getNonExistingName($name) {
  385. return $this->__call(__FUNCTION__, func_get_args());
  386. }
  387. /**
  388. * @inheritDoc
  389. */
  390. public function move($targetPath) {
  391. return $this->__call(__FUNCTION__, func_get_args());
  392. }
  393. /**
  394. * @inheritDoc
  395. */
  396. public function lock($type) {
  397. return $this->__call(__FUNCTION__, func_get_args());
  398. }
  399. /**
  400. * @inheritDoc
  401. */
  402. public function changeLock($targetType) {
  403. return $this->__call(__FUNCTION__, func_get_args());
  404. }
  405. /**
  406. * @inheritDoc
  407. */
  408. public function unlock($type) {
  409. return $this->__call(__FUNCTION__, func_get_args());
  410. }
  411. /**
  412. * @inheritDoc
  413. */
  414. public function getRecent($limit, $offset = 0) {
  415. return $this->__call(__FUNCTION__, func_get_args());
  416. }
  417. }