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.

294 lines
7.6 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. /**
  29. * Public interface of ownCloud for apps to use.
  30. * Files/Node interface
  31. */
  32. // use OCP namespace for all classes that are considered public.
  33. // This means that they should be used by apps instead of the internal ownCloud classes
  34. namespace OCP\Files;
  35. use OCP\Lock\LockedException;
  36. /**
  37. * Interface Node
  38. *
  39. * @since 6.0.0 - extends FileInfo was added in 8.0.0
  40. */
  41. interface Node extends FileInfo {
  42. /**
  43. * Move the file or folder to a new location
  44. *
  45. * @param string $targetPath the absolute target path
  46. * @return Node
  47. * @throws NotFoundException
  48. * @throws NotPermittedException if move not allowed or failed
  49. * @throws LockedException
  50. * @throws InvalidPathException
  51. * @since 6.0.0
  52. */
  53. public function move($targetPath);
  54. /**
  55. * Delete the file or folder
  56. *
  57. * @return void
  58. * @throws NotPermittedException
  59. * @throws InvalidPathException
  60. * @throws NotFoundException
  61. * @since 6.0.0
  62. */
  63. public function delete();
  64. /**
  65. * Cope the file or folder to a new location
  66. *
  67. * @param string $targetPath the absolute target path
  68. * @return Node
  69. * @since 6.0.0
  70. */
  71. public function copy($targetPath);
  72. /**
  73. * Change the modified date of the file or folder
  74. * If $mtime is omitted the current time will be used
  75. *
  76. * @param int $mtime (optional) modified date as unix timestamp
  77. * @throws InvalidPathException
  78. * @throws NotFoundException
  79. * @throws NotPermittedException
  80. * @return void
  81. * @since 6.0.0
  82. */
  83. public function touch($mtime = null);
  84. /**
  85. * Get the storage backend the file or folder is stored on
  86. *
  87. * @return Storage
  88. * @throws NotFoundException
  89. * @since 6.0.0
  90. */
  91. public function getStorage();
  92. /**
  93. * Get the full path of the file or folder
  94. *
  95. * @return string
  96. * @since 6.0.0
  97. */
  98. public function getPath();
  99. /**
  100. * Get the path of the file or folder relative to the mountpoint of it's storage
  101. *
  102. * @return string
  103. * @since 6.0.0
  104. */
  105. public function getInternalPath();
  106. /**
  107. * Get the internal file id for the file or folder
  108. *
  109. * @return int
  110. * @throws InvalidPathException
  111. * @throws NotFoundException
  112. * @since 6.0.0
  113. */
  114. public function getId();
  115. /**
  116. * Get metadata of the file or folder
  117. * The returned array contains the following values:
  118. * - mtime
  119. * - size
  120. *
  121. * @return array
  122. * @since 6.0.0
  123. */
  124. public function stat();
  125. /**
  126. * Get the modified date of the file or folder as unix timestamp
  127. *
  128. * @return int
  129. * @throws InvalidPathException
  130. * @throws NotFoundException
  131. * @since 6.0.0
  132. */
  133. public function getMTime();
  134. /**
  135. * Get the size of the file or folder in bytes
  136. *
  137. * @param bool $includeMounts
  138. * @return int
  139. * @throws InvalidPathException
  140. * @throws NotFoundException
  141. * @since 6.0.0
  142. */
  143. public function getSize($includeMounts = true);
  144. /**
  145. * Get the Etag of the file or folder
  146. * The Etag is an string id used to detect changes to a file or folder,
  147. * every time the file or folder is changed the Etag will change to
  148. *
  149. * @return string
  150. * @throws InvalidPathException
  151. * @throws NotFoundException
  152. * @since 6.0.0
  153. */
  154. public function getEtag();
  155. /**
  156. * Get the permissions of the file or folder as a combination of one or more of the following constants:
  157. * - \OCP\Constants::PERMISSION_READ
  158. * - \OCP\Constants::PERMISSION_UPDATE
  159. * - \OCP\Constants::PERMISSION_CREATE
  160. * - \OCP\Constants::PERMISSION_DELETE
  161. * - \OCP\Constants::PERMISSION_SHARE
  162. *
  163. * @return int
  164. * @throws InvalidPathException
  165. * @throws NotFoundException
  166. * @since 6.0.0 - namespace of constants has changed in 8.0.0
  167. */
  168. public function getPermissions();
  169. /**
  170. * Check if the file or folder is readable
  171. *
  172. * @return bool
  173. * @throws InvalidPathException
  174. * @throws NotFoundException
  175. * @since 6.0.0
  176. */
  177. public function isReadable();
  178. /**
  179. * Check if the file or folder is writable
  180. *
  181. * @return bool
  182. * @throws InvalidPathException
  183. * @throws NotFoundException
  184. * @since 6.0.0
  185. */
  186. public function isUpdateable();
  187. /**
  188. * Check if the file or folder is deletable
  189. *
  190. * @return bool
  191. * @throws InvalidPathException
  192. * @throws NotFoundException
  193. * @since 6.0.0
  194. */
  195. public function isDeletable();
  196. /**
  197. * Check if the file or folder is shareable
  198. *
  199. * @return bool
  200. * @throws InvalidPathException
  201. * @throws NotFoundException
  202. * @since 6.0.0
  203. */
  204. public function isShareable();
  205. /**
  206. * Get the parent folder of the file or folder
  207. *
  208. * @return Folder
  209. * @since 6.0.0
  210. */
  211. public function getParent();
  212. /**
  213. * Get the filename of the file or folder
  214. *
  215. * @return string
  216. * @since 6.0.0
  217. */
  218. public function getName();
  219. /**
  220. * Acquire a lock on this file or folder.
  221. *
  222. * A shared (read) lock will prevent any exclusive (write) locks from being created but any number of shared locks
  223. * can be active at the same time.
  224. * An exclusive lock will prevent any other lock from being created (both shared and exclusive).
  225. *
  226. * A locked exception will be thrown if any conflicting lock already exists
  227. *
  228. * Note that this uses mandatory locking, if you acquire an exclusive lock on a file it will block *all*
  229. * other operations for that file, even within the same php process.
  230. *
  231. * Acquiring any lock on a file will also create a shared lock on all parent folders of that file.
  232. *
  233. * Note that in most cases you won't need to manually manage the locks for any files you're working with,
  234. * any filesystem operation will automatically acquire the relevant locks for that operation.
  235. *
  236. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  237. * @throws LockedException
  238. * @since 9.1.0
  239. */
  240. public function lock($type);
  241. /**
  242. * Check the type of an existing lock.
  243. *
  244. * A shared lock can be changed to an exclusive lock is there is exactly one shared lock on the file,
  245. * an exclusive lock can always be changed to a shared lock since there can only be one exclusive lock int he first place.
  246. *
  247. * A locked exception will be thrown when these preconditions are not met.
  248. * Note that this is also the case if no existing lock exists for the file.
  249. *
  250. * @param int $targetType \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  251. * @throws LockedException
  252. * @since 9.1.0
  253. */
  254. public function changeLock($targetType);
  255. /**
  256. * Release an existing lock.
  257. *
  258. * This will also free up the shared locks on any parent folder that were automatically acquired when locking the file.
  259. *
  260. * Note that this method will not give any sort of error when trying to free a lock that doesn't exist.
  261. *
  262. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  263. * @throws LockedException
  264. * @since 9.1.0
  265. */
  266. public function unlock($type);
  267. }