Node.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. * @package OCP\Files
  40. * @since 6.0.0 - extends FileInfo was added in 8.0.0
  41. */
  42. interface Node extends FileInfo {
  43. /**
  44. * Move the file or folder to a new location
  45. *
  46. * @param string $targetPath the absolute target path
  47. * @return Node
  48. * @throws NotFoundException
  49. * @throws NotPermittedException if move not allowed or failed
  50. * @throws LockedException
  51. * @throws InvalidPathException
  52. * @since 6.0.0
  53. */
  54. public function move($targetPath);
  55. /**
  56. * Delete the file or folder
  57. *
  58. * @return void
  59. * @throws NotPermittedException
  60. * @throws InvalidPathException
  61. * @throws NotFoundException
  62. * @since 6.0.0
  63. */
  64. public function delete();
  65. /**
  66. * Cope the file or folder to a new location
  67. *
  68. * @param string $targetPath the absolute target path
  69. * @return Node
  70. * @since 6.0.0
  71. */
  72. public function copy($targetPath);
  73. /**
  74. * Change the modified date of the file or folder
  75. * If $mtime is omitted the current time will be used
  76. *
  77. * @param int $mtime (optional) modified date as unix timestamp
  78. * @throws InvalidPathException
  79. * @throws NotFoundException
  80. * @throws NotPermittedException
  81. * @return void
  82. * @since 6.0.0
  83. */
  84. public function touch($mtime = null);
  85. /**
  86. * Get the storage backend the file or folder is stored on
  87. *
  88. * @return Storage
  89. * @throws NotFoundException
  90. * @since 6.0.0
  91. */
  92. public function getStorage();
  93. /**
  94. * Get the full path of the file or folder
  95. *
  96. * @return string
  97. * @since 6.0.0
  98. */
  99. public function getPath();
  100. /**
  101. * Get the path of the file or folder relative to the mountpoint of it's storage
  102. *
  103. * @return string
  104. * @since 6.0.0
  105. */
  106. public function getInternalPath();
  107. /**
  108. * Get the internal file id for the file or folder
  109. *
  110. * @return int
  111. * @throws InvalidPathException
  112. * @throws NotFoundException
  113. * @since 6.0.0
  114. */
  115. public function getId();
  116. /**
  117. * Get metadata of the file or folder
  118. * The returned array contains the following values:
  119. * - mtime
  120. * - size
  121. *
  122. * @return array
  123. * @since 6.0.0
  124. */
  125. public function stat();
  126. /**
  127. * Get the modified date of the file or folder as unix timestamp
  128. *
  129. * @return int
  130. * @throws InvalidPathException
  131. * @throws NotFoundException
  132. * @since 6.0.0
  133. */
  134. public function getMTime();
  135. /**
  136. * Get the size of the file or folder in bytes
  137. *
  138. * @param bool $includeMounts
  139. * @return int
  140. * @throws InvalidPathException
  141. * @throws NotFoundException
  142. * @since 6.0.0
  143. */
  144. public function getSize($includeMounts = true);
  145. /**
  146. * Get the Etag of the file or folder
  147. * The Etag is an string id used to detect changes to a file or folder,
  148. * every time the file or folder is changed the Etag will change to
  149. *
  150. * @return string
  151. * @throws InvalidPathException
  152. * @throws NotFoundException
  153. * @since 6.0.0
  154. */
  155. public function getEtag();
  156. /**
  157. * Get the permissions of the file or folder as a combination of one or more of the following constants:
  158. * - \OCP\Constants::PERMISSION_READ
  159. * - \OCP\Constants::PERMISSION_UPDATE
  160. * - \OCP\Constants::PERMISSION_CREATE
  161. * - \OCP\Constants::PERMISSION_DELETE
  162. * - \OCP\Constants::PERMISSION_SHARE
  163. *
  164. * @return int
  165. * @throws InvalidPathException
  166. * @throws NotFoundException
  167. * @since 6.0.0 - namespace of constants has changed in 8.0.0
  168. */
  169. public function getPermissions();
  170. /**
  171. * Check if the file or folder is readable
  172. *
  173. * @return bool
  174. * @throws InvalidPathException
  175. * @throws NotFoundException
  176. * @since 6.0.0
  177. */
  178. public function isReadable();
  179. /**
  180. * Check if the file or folder is writable
  181. *
  182. * @return bool
  183. * @throws InvalidPathException
  184. * @throws NotFoundException
  185. * @since 6.0.0
  186. */
  187. public function isUpdateable();
  188. /**
  189. * Check if the file or folder is deletable
  190. *
  191. * @return bool
  192. * @throws InvalidPathException
  193. * @throws NotFoundException
  194. * @since 6.0.0
  195. */
  196. public function isDeletable();
  197. /**
  198. * Check if the file or folder is shareable
  199. *
  200. * @return bool
  201. * @throws InvalidPathException
  202. * @throws NotFoundException
  203. * @since 6.0.0
  204. */
  205. public function isShareable();
  206. /**
  207. * Get the parent folder of the file or folder
  208. *
  209. * @return Folder
  210. * @since 6.0.0
  211. */
  212. public function getParent();
  213. /**
  214. * Get the filename of the file or folder
  215. *
  216. * @return string
  217. * @since 6.0.0
  218. */
  219. public function getName();
  220. /**
  221. * Acquire a lock on this file or folder.
  222. *
  223. * A shared (read) lock will prevent any exclusive (write) locks from being created but any number of shared locks
  224. * can be active at the same time.
  225. * An exclusive lock will prevent any other lock from being created (both shared and exclusive).
  226. *
  227. * A locked exception will be thrown if any conflicting lock already exists
  228. *
  229. * Note that this uses mandatory locking, if you acquire an exclusive lock on a file it will block *all*
  230. * other operations for that file, even within the same php process.
  231. *
  232. * Acquiring any lock on a file will also create a shared lock on all parent folders of that file.
  233. *
  234. * Note that in most cases you won't need to manually manage the locks for any files you're working with,
  235. * any filesystem operation will automatically acquire the relevant locks for that operation.
  236. *
  237. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  238. * @throws LockedException
  239. * @since 9.1.0
  240. */
  241. public function lock($type);
  242. /**
  243. * Check the type of an existing lock.
  244. *
  245. * A shared lock can be changed to an exclusive lock is there is exactly one shared lock on the file,
  246. * an exclusive lock can always be changed to a shared lock since there can only be one exclusive lock int he first place.
  247. *
  248. * A locked exception will be thrown when these preconditions are not met.
  249. * Note that this is also the case if no existing lock exists for the file.
  250. *
  251. * @param int $targetType \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  252. * @throws LockedException
  253. * @since 9.1.0
  254. */
  255. public function changeLock($targetType);
  256. /**
  257. * Release an existing lock.
  258. *
  259. * This will also free up the shared locks on any parent folder that were automatically acquired when locking the file.
  260. *
  261. * Note that this method will not give any sort of error when trying to free a lock that doesn't exist.
  262. *
  263. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  264. * @throws LockedException
  265. * @since 9.1.0
  266. */
  267. public function unlock($type);
  268. }