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.6KB

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