TrashItem.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Robin Appelman <robin@icewind.nl>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCA\Files_Trashbin\Trash;
  24. use OCP\Files\FileInfo;
  25. use OCP\IUser;
  26. class TrashItem implements ITrashItem {
  27. /** @var ITrashBackend */
  28. private $backend;
  29. /** @var string */
  30. private $orignalLocation;
  31. /** @var int */
  32. private $deletedTime;
  33. /** @var string */
  34. private $trashPath;
  35. /** @var FileInfo */
  36. private $fileInfo;
  37. /** @var IUser */
  38. private $user;
  39. public function __construct(
  40. ITrashBackend $backend,
  41. string $originalLocation,
  42. int $deletedTime,
  43. string $trashPath,
  44. FileInfo $fileInfo,
  45. IUser $user
  46. ) {
  47. $this->backend = $backend;
  48. $this->orignalLocation = $originalLocation;
  49. $this->deletedTime = $deletedTime;
  50. $this->trashPath = $trashPath;
  51. $this->fileInfo = $fileInfo;
  52. $this->user = $user;
  53. }
  54. public function getTrashBackend(): ITrashBackend {
  55. return $this->backend;
  56. }
  57. public function getOriginalLocation(): string {
  58. return $this->orignalLocation;
  59. }
  60. public function getDeletedTime(): int {
  61. return $this->deletedTime;
  62. }
  63. public function getTrashPath(): string {
  64. return $this->trashPath;
  65. }
  66. public function isRootItem(): bool {
  67. return substr_count($this->getTrashPath(), '/') === 1;
  68. }
  69. public function getUser(): IUser {
  70. return $this->user;
  71. }
  72. public function getEtag() {
  73. return $this->fileInfo->getEtag();
  74. }
  75. public function getSize($includeMounts = true) {
  76. return $this->fileInfo->getSize($includeMounts);
  77. }
  78. public function getMtime() {
  79. return $this->fileInfo->getMtime();
  80. }
  81. public function getName() {
  82. return $this->fileInfo->getName();
  83. }
  84. public function getInternalPath() {
  85. return $this->fileInfo->getInternalPath();
  86. }
  87. public function getPath() {
  88. return $this->fileInfo->getPath();
  89. }
  90. public function getMimetype() {
  91. return $this->fileInfo->getMimetype();
  92. }
  93. public function getMimePart() {
  94. return $this->fileInfo->getMimePart();
  95. }
  96. public function getStorage() {
  97. return $this->fileInfo->getStorage();
  98. }
  99. public function getId() {
  100. return $this->fileInfo->getId();
  101. }
  102. public function isEncrypted() {
  103. return $this->fileInfo->isEncrypted();
  104. }
  105. public function getPermissions() {
  106. return $this->fileInfo->getPermissions();
  107. }
  108. public function getType() {
  109. return $this->fileInfo->getType();
  110. }
  111. public function isReadable() {
  112. return $this->fileInfo->isReadable();
  113. }
  114. public function isUpdateable() {
  115. return $this->fileInfo->isUpdateable();
  116. }
  117. public function isCreatable() {
  118. return $this->fileInfo->isCreatable();
  119. }
  120. public function isDeletable() {
  121. return $this->fileInfo->isDeletable();
  122. }
  123. public function isShareable() {
  124. return $this->fileInfo->isShareable();
  125. }
  126. public function isShared() {
  127. return $this->fileInfo->isShared();
  128. }
  129. public function isMounted() {
  130. return $this->fileInfo->isMounted();
  131. }
  132. public function getMountPoint() {
  133. return $this->fileInfo->getMountPoint();
  134. }
  135. public function getOwner() {
  136. return $this->fileInfo->getOwner();
  137. }
  138. public function getChecksum() {
  139. return $this->fileInfo->getChecksum();
  140. }
  141. public function getExtension(): string {
  142. return $this->fileInfo->getExtension();
  143. }
  144. public function getTitle(): string {
  145. return $this->getOriginalLocation();
  146. }
  147. public function getCreationTime(): int {
  148. return $this->fileInfo->getCreationTime();
  149. }
  150. public function getUploadTime(): int {
  151. return $this->fileInfo->getUploadTime();
  152. }
  153. }