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.

Node.php 7.3KB

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