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 3.9KB

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