FileInfo.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Robin McCorkell <robin@mccorkell.me.uk>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP\Files;
  28. /**
  29. * Interface FileInfo
  30. *
  31. * @package OCP\Files
  32. * @since 7.0.0
  33. */
  34. interface FileInfo {
  35. /**
  36. * @since 7.0.0
  37. */
  38. const TYPE_FILE = 'file';
  39. /**
  40. * @since 7.0.0
  41. */
  42. const TYPE_FOLDER = 'dir';
  43. /**
  44. * @const \OCP\Files\FileInfo::SPACE_NOT_COMPUTED Return value for a not computed space value
  45. * @since 8.0.0
  46. */
  47. const SPACE_NOT_COMPUTED = -1;
  48. /**
  49. * @const \OCP\Files\FileInfo::SPACE_UNKNOWN Return value for unknown space value
  50. * @since 8.0.0
  51. */
  52. const SPACE_UNKNOWN = -2;
  53. /**
  54. * @const \OCP\Files\FileInfo::SPACE_UNLIMITED Return value for unlimited space
  55. * @since 8.0.0
  56. */
  57. const SPACE_UNLIMITED = -3;
  58. /**
  59. * @since 9.1.0
  60. */
  61. const MIMETYPE_FOLDER = 'httpd/unix-directory';
  62. /**
  63. * Get the Etag of the file or folder
  64. *
  65. * @return string
  66. * @since 7.0.0
  67. */
  68. public function getEtag();
  69. /**
  70. * Get the size in bytes for the file or folder
  71. *
  72. * @return int
  73. * @since 7.0.0
  74. */
  75. public function getSize();
  76. /**
  77. * Get the last modified date as timestamp for the file or folder
  78. *
  79. * @return int
  80. * @since 7.0.0
  81. */
  82. public function getMtime();
  83. /**
  84. * Get the name of the file or folder
  85. *
  86. * @return string
  87. * @since 7.0.0
  88. */
  89. public function getName();
  90. /**
  91. * Get the path relative to the storage
  92. *
  93. * @return string
  94. * @since 7.0.0
  95. */
  96. public function getInternalPath();
  97. /**
  98. * Get the absolute path
  99. *
  100. * @return string
  101. * @since 7.0.0
  102. */
  103. public function getPath();
  104. /**
  105. * Get the full mimetype of the file or folder i.e. 'image/png'
  106. *
  107. * @return string
  108. * @since 7.0.0
  109. */
  110. public function getMimetype();
  111. /**
  112. * Get the first part of the mimetype of the file or folder i.e. 'image'
  113. *
  114. * @return string
  115. * @since 7.0.0
  116. */
  117. public function getMimePart();
  118. /**
  119. * Get the storage the file or folder is storage on
  120. *
  121. * @return \OCP\Files\Storage
  122. * @since 7.0.0
  123. */
  124. public function getStorage();
  125. /**
  126. * Get the file id of the file or folder
  127. *
  128. * @return int
  129. * @since 7.0.0
  130. */
  131. public function getId();
  132. /**
  133. * Check whether the file is encrypted
  134. *
  135. * @return bool
  136. * @since 7.0.0
  137. */
  138. public function isEncrypted();
  139. /**
  140. * Get the permissions of the file or folder as bitmasked combination of the following constants
  141. * \OCP\Constants::PERMISSION_CREATE
  142. * \OCP\Constants::PERMISSION_READ
  143. * \OCP\Constants::PERMISSION_UPDATE
  144. * \OCP\Constants::PERMISSION_DELETE
  145. * \OCP\Constants::PERMISSION_SHARE
  146. * \OCP\Constants::PERMISSION_ALL
  147. *
  148. * @return int
  149. * @since 7.0.0 - namespace of constants has changed in 8.0.0
  150. */
  151. public function getPermissions();
  152. /**
  153. * Check whether this is a file or a folder
  154. *
  155. * @return \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
  156. * @since 7.0.0
  157. */
  158. public function getType();
  159. /**
  160. * Check if the file or folder is readable
  161. *
  162. * @return bool
  163. * @since 7.0.0
  164. */
  165. public function isReadable();
  166. /**
  167. * Check if a file is writable
  168. *
  169. * @return bool
  170. * @since 7.0.0
  171. */
  172. public function isUpdateable();
  173. /**
  174. * Check whether new files or folders can be created inside this folder
  175. *
  176. * @return bool
  177. * @since 8.0.0
  178. */
  179. public function isCreatable();
  180. /**
  181. * Check if a file or folder can be deleted
  182. *
  183. * @return bool
  184. * @since 7.0.0
  185. */
  186. public function isDeletable();
  187. /**
  188. * Check if a file or folder can be shared
  189. *
  190. * @return bool
  191. * @since 7.0.0
  192. */
  193. public function isShareable();
  194. /**
  195. * Check if a file or folder is shared
  196. *
  197. * @return bool
  198. * @since 7.0.0
  199. */
  200. public function isShared();
  201. /**
  202. * Check if a file or folder is mounted
  203. *
  204. * @return bool
  205. * @since 7.0.0
  206. */
  207. public function isMounted();
  208. /**
  209. * Get the mountpoint the file belongs to
  210. *
  211. * @return \OCP\Files\Mount\IMountPoint
  212. * @since 8.0.0
  213. */
  214. public function getMountPoint();
  215. /**
  216. * Get the owner of the file
  217. *
  218. * @return \OCP\IUser
  219. * @since 9.0.0
  220. */
  221. public function getOwner();
  222. /**
  223. * Get the stored checksum for this file
  224. *
  225. * @return string
  226. * @since 9.0.0
  227. */
  228. public function getChecksum();
  229. }