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.

TrashItem.php 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Maxence Lange <maxence@artificial-owl.com>
  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 OCA\Files_Trashbin\Trash;
  25. use OCP\Files\FileInfo;
  26. use OCP\IUser;
  27. class TrashItem implements ITrashItem {
  28. /** @var ITrashBackend */
  29. private $backend;
  30. /** @var string */
  31. private $orignalLocation;
  32. /** @var int */
  33. private $deletedTime;
  34. /** @var string */
  35. private $trashPath;
  36. /** @var FileInfo */
  37. private $fileInfo;
  38. /** @var IUser */
  39. private $user;
  40. public function __construct(
  41. ITrashBackend $backend,
  42. string $originalLocation,
  43. int $deletedTime,
  44. string $trashPath,
  45. FileInfo $fileInfo,
  46. IUser $user
  47. ) {
  48. $this->backend = $backend;
  49. $this->orignalLocation = $originalLocation;
  50. $this->deletedTime = $deletedTime;
  51. $this->trashPath = $trashPath;
  52. $this->fileInfo = $fileInfo;
  53. $this->user = $user;
  54. }
  55. public function getTrashBackend(): ITrashBackend {
  56. return $this->backend;
  57. }
  58. public function getOriginalLocation(): string {
  59. return $this->orignalLocation;
  60. }
  61. public function getDeletedTime(): int {
  62. return $this->deletedTime;
  63. }
  64. public function getTrashPath(): string {
  65. return $this->trashPath;
  66. }
  67. public function isRootItem(): bool {
  68. return substr_count($this->getTrashPath(), '/') === 1;
  69. }
  70. public function getUser(): IUser {
  71. return $this->user;
  72. }
  73. public function getEtag() {
  74. return $this->fileInfo->getEtag();
  75. }
  76. public function getSize($includeMounts = true) {
  77. return $this->fileInfo->getSize($includeMounts);
  78. }
  79. public function getMtime() {
  80. return $this->fileInfo->getMtime();
  81. }
  82. public function getName() {
  83. return $this->fileInfo->getName();
  84. }
  85. public function getInternalPath() {
  86. return $this->fileInfo->getInternalPath();
  87. }
  88. public function getPath() {
  89. return $this->fileInfo->getPath();
  90. }
  91. public function getMimetype() {
  92. return $this->fileInfo->getMimetype();
  93. }
  94. public function getMimePart() {
  95. return $this->fileInfo->getMimePart();
  96. }
  97. public function getStorage() {
  98. return $this->fileInfo->getStorage();
  99. }
  100. public function getId() {
  101. return $this->fileInfo->getId();
  102. }
  103. public function isEncrypted() {
  104. return $this->fileInfo->isEncrypted();
  105. }
  106. public function getPermissions() {
  107. return $this->fileInfo->getPermissions();
  108. }
  109. public function getType() {
  110. return $this->fileInfo->getType();
  111. }
  112. public function isReadable() {
  113. return $this->fileInfo->isReadable();
  114. }
  115. public function isUpdateable() {
  116. return $this->fileInfo->isUpdateable();
  117. }
  118. public function isCreatable() {
  119. return $this->fileInfo->isCreatable();
  120. }
  121. public function isDeletable() {
  122. return $this->fileInfo->isDeletable();
  123. }
  124. public function isShareable() {
  125. return $this->fileInfo->isShareable();
  126. }
  127. public function isShared() {
  128. return $this->fileInfo->isShared();
  129. }
  130. public function isMounted() {
  131. return $this->fileInfo->isMounted();
  132. }
  133. public function getMountPoint() {
  134. return $this->fileInfo->getMountPoint();
  135. }
  136. public function getOwner() {
  137. return $this->fileInfo->getOwner();
  138. }
  139. public function getChecksum() {
  140. return $this->fileInfo->getChecksum();
  141. }
  142. public function getExtension(): string {
  143. return $this->fileInfo->getExtension();
  144. }
  145. public function getTitle(): string {
  146. return $this->getOriginalLocation();
  147. }
  148. public function getCreationTime(): int {
  149. return $this->fileInfo->getCreationTime();
  150. }
  151. public function getUploadTime(): int {
  152. return $this->fileInfo->getUploadTime();
  153. }
  154. public function getParentId(): int {
  155. return $this->fileInfo->getParentId();
  156. }
  157. /**
  158. * @inheritDoc
  159. * @return array<string, int|string|bool|float|string[]|int[]>
  160. */
  161. public function getMetadata(): array {
  162. return $this->fileInfo->getMetadata();
  163. }
  164. }