1
0

NullStorage.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OC\Lockdown\Filesystem;
  25. use Icewind\Streams\IteratorDirectory;
  26. use OC\Files\FileInfo;
  27. use OC\Files\Storage\Common;
  28. use OCP\Files\Storage\IStorage;
  29. class NullStorage extends Common {
  30. public function __construct($parameters) {
  31. parent::__construct($parameters);
  32. }
  33. public function getId() {
  34. return 'null';
  35. }
  36. public function mkdir($path) {
  37. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  38. }
  39. public function rmdir($path) {
  40. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  41. }
  42. public function opendir($path) {
  43. return new IteratorDirectory([]);
  44. }
  45. public function is_dir($path) {
  46. return $path === '';
  47. }
  48. public function is_file($path) {
  49. return false;
  50. }
  51. public function stat($path) {
  52. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  53. }
  54. public function filetype($path) {
  55. return ($path === '') ? 'dir' : false;
  56. }
  57. public function filesize($path): false|int|float {
  58. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  59. }
  60. public function isCreatable($path) {
  61. return false;
  62. }
  63. public function isReadable($path) {
  64. return $path === '';
  65. }
  66. public function isUpdatable($path) {
  67. return false;
  68. }
  69. public function isDeletable($path) {
  70. return false;
  71. }
  72. public function isSharable($path) {
  73. return false;
  74. }
  75. public function getPermissions($path) {
  76. return null;
  77. }
  78. public function file_exists($path) {
  79. return $path === '';
  80. }
  81. public function filemtime($path) {
  82. return ($path === '') ? time() : false;
  83. }
  84. public function file_get_contents($path) {
  85. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  86. }
  87. public function file_put_contents($path, $data) {
  88. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  89. }
  90. public function unlink($path) {
  91. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  92. }
  93. public function rename($source, $target) {
  94. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  95. }
  96. public function copy($source, $target) {
  97. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  98. }
  99. public function fopen($path, $mode) {
  100. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  101. }
  102. public function getMimeType($path) {
  103. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  104. }
  105. public function hash($type, $path, $raw = false) {
  106. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  107. }
  108. public function free_space($path) {
  109. return FileInfo::SPACE_UNKNOWN;
  110. }
  111. public function touch($path, $mtime = null) {
  112. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  113. }
  114. public function getLocalFile($path) {
  115. return false;
  116. }
  117. public function hasUpdated($path, $time) {
  118. return false;
  119. }
  120. public function getETag($path) {
  121. return '';
  122. }
  123. public function isLocal() {
  124. return false;
  125. }
  126. public function getDirectDownload($path) {
  127. return false;
  128. }
  129. public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
  130. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  131. }
  132. public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
  133. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  134. }
  135. public function test() {
  136. return true;
  137. }
  138. public function getOwner($path) {
  139. return null;
  140. }
  141. public function getCache($path = '', $storage = null) {
  142. return new NullCache();
  143. }
  144. }