Folder.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. * get a file or folder inside the folder by it's internal id
  132. *
  133. * This method could return multiple entries. For example once the file/folder
  134. * is shared or mounted (files_external) to the user multiple times.
  135. *
  136. * @param int $id
  137. * @return \OCP\Files\Node[]
  138. * @since 6.0.0
  139. */
  140. public function getById($id);
  141. /**
  142. * Get the amount of free space inside the folder
  143. *
  144. * @return int
  145. * @since 6.0.0
  146. */
  147. public function getFreeSpace();
  148. /**
  149. * Check if new files or folders can be created within the folder
  150. *
  151. * @return bool
  152. * @since 6.0.0
  153. */
  154. public function isCreatable();
  155. /**
  156. * Add a suffix to the name in case the file exists
  157. *
  158. * @param string $name
  159. * @return string
  160. * @throws NotPermittedException
  161. * @since 8.1.0
  162. */
  163. public function getNonExistingName($name);
  164. /**
  165. * @param int $limit
  166. * @param int $offset
  167. * @return \OCP\Files\Node[]
  168. * @since 9.1.0
  169. */
  170. public function getRecent($limit, $offset = 0);
  171. }