1
0

Node.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. * @param bool $includeMounts
  127. * @return int
  128. * @throws InvalidPathException
  129. * @throws NotFoundException
  130. * @since 6.0.0
  131. */
  132. public function getSize($includeMounts = true);
  133. /**
  134. * Get the Etag of the file or folder
  135. * The Etag is an string id used to detect changes to a file or folder,
  136. * every time the file or folder is changed the Etag will change to
  137. *
  138. * @return string
  139. * @throws InvalidPathException
  140. * @throws NotFoundException
  141. * @since 6.0.0
  142. */
  143. public function getEtag();
  144. /**
  145. * Get the permissions of the file or folder as a combination of one or more of the following constants:
  146. * - \OCP\Constants::PERMISSION_READ
  147. * - \OCP\Constants::PERMISSION_UPDATE
  148. * - \OCP\Constants::PERMISSION_CREATE
  149. * - \OCP\Constants::PERMISSION_DELETE
  150. * - \OCP\Constants::PERMISSION_SHARE
  151. *
  152. * @return int
  153. * @throws InvalidPathException
  154. * @throws NotFoundException
  155. * @since 6.0.0 - namespace of constants has changed in 8.0.0
  156. */
  157. public function getPermissions();
  158. /**
  159. * Check if the file or folder is readable
  160. *
  161. * @return bool
  162. * @throws InvalidPathException
  163. * @throws NotFoundException
  164. * @since 6.0.0
  165. */
  166. public function isReadable();
  167. /**
  168. * Check if the file or folder is writable
  169. *
  170. * @return bool
  171. * @throws InvalidPathException
  172. * @throws NotFoundException
  173. * @since 6.0.0
  174. */
  175. public function isUpdateable();
  176. /**
  177. * Check if the file or folder is deletable
  178. *
  179. * @return bool
  180. * @throws InvalidPathException
  181. * @throws NotFoundException
  182. * @since 6.0.0
  183. */
  184. public function isDeletable();
  185. /**
  186. * Check if the file or folder is shareable
  187. *
  188. * @return bool
  189. * @throws InvalidPathException
  190. * @throws NotFoundException
  191. * @since 6.0.0
  192. */
  193. public function isShareable();
  194. /**
  195. * Get the parent folder of the file or folder
  196. *
  197. * @return Folder
  198. * @since 6.0.0
  199. */
  200. public function getParent();
  201. /**
  202. * Get the filename of the file or folder
  203. *
  204. * @return string
  205. * @since 6.0.0
  206. */
  207. public function getName();
  208. /**
  209. * Acquire a lock on this file or folder.
  210. *
  211. * A shared (read) lock will prevent any exclusive (write) locks from being created but any number of shared locks
  212. * can be active at the same time.
  213. * An exclusive lock will prevent any other lock from being created (both shared and exclusive).
  214. *
  215. * A locked exception will be thrown if any conflicting lock already exists
  216. *
  217. * Note that this uses mandatory locking, if you acquire an exclusive lock on a file it will block *all*
  218. * other operations for that file, even within the same php process.
  219. *
  220. * Acquiring any lock on a file will also create a shared lock on all parent folders of that file.
  221. *
  222. * Note that in most cases you won't need to manually manage the locks for any files you're working with,
  223. * any filesystem operation will automatically acquire the relevant locks for that operation.
  224. *
  225. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  226. * @throws \OCP\Lock\LockedException
  227. * @since 9.1.0
  228. */
  229. public function lock($type);
  230. /**
  231. * Check the type of an existing lock.
  232. *
  233. * A shared lock can be changed to an exclusive lock is there is exactly one shared lock on the file,
  234. * an exclusive lock can always be changed to a shared lock since there can only be one exclusive lock int he first place.
  235. *
  236. * A locked exception will be thrown when these preconditions are not met.
  237. * Note that this is also the case if no existing lock exists for the file.
  238. *
  239. * @param int $targetType \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  240. * @throws \OCP\Lock\LockedException
  241. * @since 9.1.0
  242. */
  243. public function changeLock($targetType);
  244. /**
  245. * Release an existing lock.
  246. *
  247. * This will also free up the shared locks on any parent folder that were automatically acquired when locking the file.
  248. *
  249. * Note that this method will not give any sort of error when trying to free a lock that doesn't exist.
  250. *
  251. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  252. * @throws \OCP\Lock\LockedException
  253. * @since 9.1.0
  254. */
  255. public function unlock($type);
  256. }