You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.3 KiB

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