Node.php 7.6 KB

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