1
0

NullStorage.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Lockdown\Filesystem;
  7. use Icewind\Streams\IteratorDirectory;
  8. use OC\Files\FileInfo;
  9. use OC\Files\Storage\Common;
  10. use OCP\Files\Storage\IStorage;
  11. class NullStorage extends Common {
  12. public function __construct($parameters) {
  13. parent::__construct($parameters);
  14. }
  15. public function getId() {
  16. return 'null';
  17. }
  18. public function mkdir($path) {
  19. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  20. }
  21. public function rmdir($path) {
  22. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  23. }
  24. public function opendir($path) {
  25. return new IteratorDirectory([]);
  26. }
  27. public function is_dir($path) {
  28. return $path === '';
  29. }
  30. public function is_file($path) {
  31. return false;
  32. }
  33. public function stat($path) {
  34. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  35. }
  36. public function filetype($path) {
  37. return ($path === '') ? 'dir' : false;
  38. }
  39. public function filesize($path): false|int|float {
  40. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  41. }
  42. public function isCreatable($path) {
  43. return false;
  44. }
  45. public function isReadable($path) {
  46. return $path === '';
  47. }
  48. public function isUpdatable($path) {
  49. return false;
  50. }
  51. public function isDeletable($path) {
  52. return false;
  53. }
  54. public function isSharable($path) {
  55. return false;
  56. }
  57. public function getPermissions($path) {
  58. return null;
  59. }
  60. public function file_exists($path) {
  61. return $path === '';
  62. }
  63. public function filemtime($path) {
  64. return ($path === '') ? time() : false;
  65. }
  66. public function file_get_contents($path) {
  67. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  68. }
  69. public function file_put_contents($path, $data) {
  70. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  71. }
  72. public function unlink($path) {
  73. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  74. }
  75. public function rename($source, $target) {
  76. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  77. }
  78. public function copy($source, $target) {
  79. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  80. }
  81. public function fopen($path, $mode) {
  82. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  83. }
  84. public function getMimeType($path) {
  85. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  86. }
  87. public function hash($type, $path, $raw = false) {
  88. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  89. }
  90. public function free_space($path) {
  91. return FileInfo::SPACE_UNKNOWN;
  92. }
  93. public function touch($path, $mtime = null) {
  94. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  95. }
  96. public function getLocalFile($path) {
  97. return false;
  98. }
  99. public function hasUpdated($path, $time) {
  100. return false;
  101. }
  102. public function getETag($path) {
  103. return '';
  104. }
  105. public function isLocal() {
  106. return false;
  107. }
  108. public function getDirectDownload($path) {
  109. return false;
  110. }
  111. public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
  112. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  113. }
  114. public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
  115. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  116. }
  117. public function test() {
  118. return true;
  119. }
  120. public function getOwner($path) {
  121. return null;
  122. }
  123. public function getCache($path = '', $storage = null) {
  124. return new NullCache();
  125. }
  126. }