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.

195 lines
4.7 KiB

3 years ago
  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 <pvince81@owncloud.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. /**
  27. * Public interface of ownCloud for apps to use.
  28. * Files/Folder interface
  29. */
  30. // use OCP namespace for all classes that are considered public.
  31. // This means that they should be used by apps instead of the internal ownCloud classes
  32. namespace OCP\Files;
  33. use OCP\Files\Search\ISearchQuery;
  34. /**
  35. * @since 6.0.0
  36. */
  37. interface Folder extends Node {
  38. /**
  39. * Get the full path of an item in the folder within owncloud's filesystem
  40. *
  41. * @param string $path relative path of an item in the folder
  42. * @return string
  43. * @throws \OCP\Files\NotPermittedException
  44. * @since 6.0.0
  45. */
  46. public function getFullPath($path);
  47. /**
  48. * Get the path of an item in the folder relative to the folder
  49. *
  50. * @param string $path absolute path of an item in the folder
  51. * @throws \OCP\Files\NotFoundException
  52. * @return string
  53. * @since 6.0.0
  54. */
  55. public function getRelativePath($path);
  56. /**
  57. * check if a node is a (grand-)child of the folder
  58. *
  59. * @param \OCP\Files\Node $node
  60. * @return bool
  61. * @since 6.0.0
  62. */
  63. public function isSubNode($node);
  64. /**
  65. * get the content of this directory
  66. *
  67. * @throws \OCP\Files\NotFoundException
  68. * @return \OCP\Files\Node[]
  69. * @since 6.0.0
  70. */
  71. public function getDirectoryListing();
  72. /**
  73. * Get the node at $path
  74. *
  75. * @param string $path relative path of the file or folder
  76. * @return \OCP\Files\Node
  77. * @throws \OCP\Files\NotFoundException
  78. * @since 6.0.0
  79. */
  80. public function get($path);
  81. /**
  82. * Check if a file or folder exists in the folder
  83. *
  84. * @param string $path relative path of the file or folder
  85. * @return bool
  86. * @since 6.0.0
  87. */
  88. public function nodeExists($path);
  89. /**
  90. * Create a new folder
  91. *
  92. * @param string $path relative path of the new folder
  93. * @return \OCP\Files\Folder
  94. * @throws \OCP\Files\NotPermittedException
  95. * @since 6.0.0
  96. */
  97. public function newFolder($path);
  98. /**
  99. * Create a new file
  100. *
  101. * @param string $path relative path of the new file
  102. * @param string|resource|null $content content for the new file, since 19.0.0
  103. * @return \OCP\Files\File
  104. * @throws \OCP\Files\NotPermittedException
  105. * @since 6.0.0
  106. */
  107. public function newFile($path, $content = null);
  108. /**
  109. * search for files with the name matching $query
  110. *
  111. * @param string|ISearchQuery $query
  112. * @return \OCP\Files\Node[]
  113. * @since 6.0.0
  114. */
  115. public function search($query);
  116. /**
  117. * search for files by mimetype
  118. * $mimetype can either be a full mimetype (image/png) or a wildcard mimetype (image)
  119. *
  120. * @param string $mimetype
  121. * @return \OCP\Files\Node[]
  122. * @since 6.0.0
  123. */
  124. public function searchByMime($mimetype);
  125. /**
  126. * search for files by tag
  127. *
  128. * @param string|int $tag tag name or tag id
  129. * @param string $userId owner of the tags
  130. * @return \OCP\Files\Node[]
  131. * @since 8.0.0
  132. */
  133. public function searchByTag($tag, $userId);
  134. /**
  135. * get a file or folder inside the folder by it's internal id
  136. *
  137. * This method could return multiple entries. For example once the file/folder
  138. * is shared or mounted (files_external) to the user multiple times.
  139. *
  140. * @param int $id
  141. * @return \OCP\Files\Node[]
  142. * @since 6.0.0
  143. */
  144. public function getById($id);
  145. /**
  146. * Get the amount of free space inside the folder
  147. *
  148. * @return int
  149. * @since 6.0.0
  150. */
  151. public function getFreeSpace();
  152. /**
  153. * Check if new files or folders can be created within the folder
  154. *
  155. * @return bool
  156. * @since 6.0.0
  157. */
  158. public function isCreatable();
  159. /**
  160. * Add a suffix to the name in case the file exists
  161. *
  162. * @param string $name
  163. * @return string
  164. * @throws NotPermittedException
  165. * @since 8.1.0
  166. */
  167. public function getNonExistingName($name);
  168. /**
  169. * @param int $limit
  170. * @param int $offset
  171. * @return \OCP\Files\Node[]
  172. * @since 9.1.0
  173. */
  174. public function getRecent($limit, $offset = 0);
  175. }