123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- /**
- * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
- namespace OC\Lockdown\Filesystem;
- use Icewind\Streams\IteratorDirectory;
- use OC\Files\FileInfo;
- use OC\Files\Storage\Common;
- use OCP\Files\Cache\ICache;
- use OCP\Files\Storage\IStorage;
- class NullStorage extends Common {
- public function __construct($parameters) {
- parent::__construct($parameters);
- }
- public function getId(): string {
- return 'null';
- }
- public function mkdir($path): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function rmdir($path): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function opendir($path): IteratorDirectory {
- return new IteratorDirectory([]);
- }
- public function is_dir($path): bool {
- return $path === '';
- }
- public function is_file($path): bool {
- return false;
- }
- public function stat($path): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function filetype($path): string|false {
- return ($path === '') ? 'dir' : false;
- }
- public function filesize($path): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function isCreatable($path): bool {
- return false;
- }
- public function isReadable($path): bool {
- return $path === '';
- }
- public function isUpdatable($path): bool {
- return false;
- }
- public function isDeletable($path): bool {
- return false;
- }
- public function isSharable($path): bool {
- return false;
- }
- public function getPermissions($path): int {
- return 0;
- }
- public function file_exists($path): bool {
- return $path === '';
- }
- public function filemtime($path): int|false {
- return ($path === '') ? time() : false;
- }
- public function file_get_contents($path): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function file_put_contents($path, $data): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function unlink($path): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function rename($source, $target): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function copy($source, $target): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function fopen($path, $mode): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function getMimeType($path): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function hash($type, $path, $raw = false): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function free_space($path): int {
- return FileInfo::SPACE_UNKNOWN;
- }
- public function touch($path, $mtime = null): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function getLocalFile($path): string|false {
- return false;
- }
- public function hasUpdated($path, $time): bool {
- return false;
- }
- public function getETag($path): string {
- return '';
- }
- public function isLocal(): bool {
- return false;
- }
- public function getDirectDownload($path): array|false {
- return false;
- }
- public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): never {
- throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
- }
- public function test(): bool {
- return true;
- }
- public function getOwner($path): string|false {
- return false;
- }
- public function getCache($path = '', $storage = null): ICache {
- return new NullCache();
- }
- }
|