NonExistingFile.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Files\Node;
  8. use OCP\Files\NotFoundException;
  9. class NonExistingFile extends File {
  10. /**
  11. * @param string $newPath
  12. * @throws \OCP\Files\NotFoundException
  13. */
  14. public function rename($newPath) {
  15. throw new NotFoundException();
  16. }
  17. public function delete() {
  18. throw new NotFoundException();
  19. }
  20. public function copy($targetPath) {
  21. throw new NotFoundException();
  22. }
  23. public function touch($mtime = null) {
  24. throw new NotFoundException();
  25. }
  26. public function getId() {
  27. if ($this->fileInfo) {
  28. return parent::getId();
  29. } else {
  30. throw new NotFoundException();
  31. }
  32. }
  33. public function getInternalPath() {
  34. if ($this->fileInfo) {
  35. return parent::getInternalPath();
  36. } else {
  37. return $this->getParent()->getMountPoint()->getInternalPath($this->getPath());
  38. }
  39. }
  40. public function stat() {
  41. throw new NotFoundException();
  42. }
  43. public function getMTime() {
  44. if ($this->fileInfo) {
  45. return parent::getMTime();
  46. } else {
  47. throw new NotFoundException();
  48. }
  49. }
  50. public function getSize($includeMounts = true): int|float {
  51. if ($this->fileInfo) {
  52. return parent::getSize($includeMounts);
  53. } else {
  54. throw new NotFoundException();
  55. }
  56. }
  57. public function getEtag() {
  58. if ($this->fileInfo) {
  59. return parent::getEtag();
  60. } else {
  61. throw new NotFoundException();
  62. }
  63. }
  64. public function getPermissions() {
  65. if ($this->fileInfo) {
  66. return parent::getPermissions();
  67. } else {
  68. throw new NotFoundException();
  69. }
  70. }
  71. public function isReadable() {
  72. if ($this->fileInfo) {
  73. return parent::isReadable();
  74. } else {
  75. throw new NotFoundException();
  76. }
  77. }
  78. public function isUpdateable() {
  79. if ($this->fileInfo) {
  80. return parent::isUpdateable();
  81. } else {
  82. throw new NotFoundException();
  83. }
  84. }
  85. public function isDeletable() {
  86. if ($this->fileInfo) {
  87. return parent::isDeletable();
  88. } else {
  89. throw new NotFoundException();
  90. }
  91. }
  92. public function isShareable() {
  93. if ($this->fileInfo) {
  94. return parent::isShareable();
  95. } else {
  96. throw new NotFoundException();
  97. }
  98. }
  99. public function getContent() {
  100. throw new NotFoundException();
  101. }
  102. public function putContent($data) {
  103. throw new NotFoundException();
  104. }
  105. public function getMimeType() {
  106. if ($this->fileInfo) {
  107. return parent::getMimeType();
  108. } else {
  109. throw new NotFoundException();
  110. }
  111. }
  112. public function fopen($mode) {
  113. throw new NotFoundException();
  114. }
  115. }