1
0

Folder.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 it's 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. * @param int $id
  146. * @return \OCP\Files\Node[]
  147. * @since 6.0.0
  148. */
  149. public function getById($id);
  150. /**
  151. * Get the amount of free space inside the folder
  152. *
  153. * @return int
  154. * @since 6.0.0
  155. */
  156. public function getFreeSpace();
  157. /**
  158. * Check if new files or folders can be created within the folder
  159. *
  160. * @return bool
  161. * @since 6.0.0
  162. */
  163. public function isCreatable();
  164. /**
  165. * Add a suffix to the name in case the file exists
  166. *
  167. * @param string $name
  168. * @return string
  169. * @throws NotPermittedException
  170. * @since 8.1.0
  171. */
  172. public function getNonExistingName($name);
  173. /**
  174. * @param int $limit
  175. * @param int $offset
  176. * @return \OCP\Files\Node[]
  177. * @since 9.1.0
  178. */
  179. public function getRecent($limit, $offset = 0);
  180. }