Folder.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Vincent Petry <vincent@nextcloud.com>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. // use OCP namespace for all classes that are considered public.
  27. // This means that they should be used by apps instead of the internal ownCloud classes
  28. namespace OCP\Files;
  29. use OCP\Files\Search\ISearchQuery;
  30. /**
  31. * @since 6.0.0
  32. */
  33. interface Folder extends Node {
  34. /**
  35. * Get the full path of an item in the folder within owncloud's filesystem
  36. *
  37. * @param string $path relative path of an item in the folder
  38. * @return string
  39. * @throws \OCP\Files\NotPermittedException
  40. * @since 6.0.0
  41. */
  42. public function getFullPath($path);
  43. /**
  44. * Get the path of an item in the folder relative to the folder
  45. *
  46. * @param string $path absolute path of an item in the folder
  47. * @throws \OCP\Files\NotFoundException
  48. * @return string|null
  49. * @since 6.0.0
  50. */
  51. public function getRelativePath($path);
  52. /**
  53. * check if a node is a (grand-)child of the folder
  54. *
  55. * @param \OCP\Files\Node $node
  56. * @return bool
  57. * @since 6.0.0
  58. */
  59. public function isSubNode($node);
  60. /**
  61. * get the content of this directory
  62. *
  63. * @throws \OCP\Files\NotFoundException
  64. * @return \OCP\Files\Node[]
  65. * @since 6.0.0
  66. */
  67. public function getDirectoryListing();
  68. /**
  69. * Get the node at $path
  70. *
  71. * @param string $path relative path of the file or folder
  72. * @return \OCP\Files\Node
  73. * @throws \OCP\Files\NotFoundException
  74. * @since 6.0.0
  75. */
  76. public function get($path);
  77. /**
  78. * Check if a file or folder exists in the folder
  79. *
  80. * @param string $path relative path of the file or folder
  81. * @return bool
  82. * @since 6.0.0
  83. */
  84. public function nodeExists($path);
  85. /**
  86. * Create a new folder
  87. *
  88. * @param string $path relative path of the new folder
  89. * @return \OCP\Files\Folder
  90. * @throws \OCP\Files\NotPermittedException
  91. * @since 6.0.0
  92. */
  93. public function newFolder($path);
  94. /**
  95. * Create a new file
  96. *
  97. * @param string $path relative path of the new file
  98. * @param string|resource|null $content content for the new file, since 19.0.0
  99. * @return \OCP\Files\File
  100. * @throws \OCP\Files\NotPermittedException
  101. * @since 6.0.0
  102. */
  103. public function newFile($path, $content = null);
  104. /**
  105. * search for files with the name matching $query
  106. *
  107. * @param string|ISearchQuery $query
  108. * @return \OCP\Files\Node[]
  109. * @since 6.0.0
  110. */
  111. public function search($query);
  112. /**
  113. * search for files by mimetype
  114. * $mimetype can either be a full mimetype (image/png) or a wildcard mimetype (image)
  115. *
  116. * @param string $mimetype
  117. * @return \OCP\Files\Node[]
  118. * @since 6.0.0
  119. */
  120. public function searchByMime($mimetype);
  121. /**
  122. * search for files by tag
  123. *
  124. * @param string|int $tag tag name or tag id
  125. * @param string $userId owner of the tags
  126. * @return \OCP\Files\Node[]
  127. * @since 8.0.0
  128. */
  129. public function searchByTag($tag, $userId);
  130. /**
  131. * search for files by system tag
  132. *
  133. * @param string|int $tag tag name
  134. * @param string $userId user id to ensure access on returned nodes
  135. * @return \OCP\Files\Node[]
  136. * @since 28.0.0
  137. */
  138. public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0);
  139. /**
  140. * get a file or folder inside the folder by its internal id
  141. *
  142. * This method could return multiple entries. For example once the file/folder
  143. * is shared or mounted (files_external) to the user multiple times.
  144. *
  145. * Note that the different entries can have different permissions.
  146. *
  147. * @param int $id
  148. * @return \OCP\Files\Node[]
  149. * @since 6.0.0
  150. */
  151. public function getById($id);
  152. /**
  153. * get a file or folder inside the folder by its internal id
  154. *
  155. * Unlike getById, this method only returns a single node even if the user has
  156. * access to the file with the requested id multiple times.
  157. *
  158. * This method provides no guarantee about which of the nodes in returned and the
  159. * returned node might, for example, have less permissions than other nodes for the same file
  160. *
  161. * Apps that require accurate information about the users access to the file should use getById
  162. * instead of pick the correct node out of the result.
  163. *
  164. * @param int $id
  165. * @return Node|null
  166. * @since 29.0.0
  167. */
  168. public function getFirstNodeById(int $id): ?Node;
  169. /**
  170. * Get the amount of free space inside the folder
  171. *
  172. * @return int
  173. * @since 6.0.0
  174. */
  175. public function getFreeSpace();
  176. /**
  177. * Check if new files or folders can be created within the folder
  178. *
  179. * @return bool
  180. * @since 6.0.0
  181. */
  182. public function isCreatable();
  183. /**
  184. * Add a suffix to the name in case the file exists
  185. *
  186. * @param string $name
  187. * @return string
  188. * @throws NotPermittedException
  189. * @since 8.1.0
  190. */
  191. public function getNonExistingName($name);
  192. /**
  193. * @param int $limit
  194. * @param int $offset
  195. * @return \OCP\Files\Node[]
  196. * @since 9.1.0
  197. */
  198. public function getRecent($limit, $offset = 0);
  199. }