FileInfo.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Felix Heidecke <felix@heidecke.me>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Julius Härtl <jus@bitgrid.net>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  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. namespace OCP\Files;
  29. /**
  30. * Interface FileInfo
  31. *
  32. * @package OCP\Files
  33. * @since 7.0.0
  34. */
  35. interface FileInfo {
  36. /**
  37. * @since 7.0.0
  38. */
  39. const TYPE_FILE = 'file';
  40. /**
  41. * @since 7.0.0
  42. */
  43. const TYPE_FOLDER = 'dir';
  44. /**
  45. * @const \OCP\Files\FileInfo::SPACE_NOT_COMPUTED Return value for a not computed space value
  46. * @since 8.0.0
  47. */
  48. const SPACE_NOT_COMPUTED = -1;
  49. /**
  50. * @const \OCP\Files\FileInfo::SPACE_UNKNOWN Return value for unknown space value
  51. * @since 8.0.0
  52. */
  53. const SPACE_UNKNOWN = -2;
  54. /**
  55. * @const \OCP\Files\FileInfo::SPACE_UNLIMITED Return value for unlimited space
  56. * @since 8.0.0
  57. */
  58. const SPACE_UNLIMITED = -3;
  59. /**
  60. * @since 9.1.0
  61. */
  62. const MIMETYPE_FOLDER = 'httpd/unix-directory';
  63. /**
  64. * @const \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX Return regular expression to test filenames against (blacklisting)
  65. * @since 12.0.0
  66. */
  67. const BLACKLIST_FILES_REGEX = '\.(part|filepart)$';
  68. /**
  69. * Get the Etag of the file or folder
  70. *
  71. * @return string
  72. * @since 7.0.0
  73. */
  74. public function getEtag();
  75. /**
  76. * Get the size in bytes for the file or folder
  77. *
  78. * @return int
  79. * @since 7.0.0
  80. */
  81. public function getSize();
  82. /**
  83. * Get the last modified date as timestamp for the file or folder
  84. *
  85. * @return int
  86. * @since 7.0.0
  87. */
  88. public function getMtime();
  89. /**
  90. * Get the name of the file or folder
  91. *
  92. * @return string
  93. * @since 7.0.0
  94. */
  95. public function getName();
  96. /**
  97. * Get the path relative to the storage
  98. *
  99. * @return string
  100. * @since 7.0.0
  101. */
  102. public function getInternalPath();
  103. /**
  104. * Get the absolute path
  105. *
  106. * @return string
  107. * @since 7.0.0
  108. */
  109. public function getPath();
  110. /**
  111. * Get the full mimetype of the file or folder i.e. 'image/png'
  112. *
  113. * @return string
  114. * @since 7.0.0
  115. */
  116. public function getMimetype();
  117. /**
  118. * Get the first part of the mimetype of the file or folder i.e. 'image'
  119. *
  120. * @return string
  121. * @since 7.0.0
  122. */
  123. public function getMimePart();
  124. /**
  125. * Get the storage the file or folder is storage on
  126. *
  127. * @return \OCP\Files\Storage
  128. * @since 7.0.0
  129. */
  130. public function getStorage();
  131. /**
  132. * Get the file id of the file or folder
  133. *
  134. * @return int|null
  135. * @since 7.0.0
  136. */
  137. public function getId();
  138. /**
  139. * Check whether the file is encrypted
  140. *
  141. * @return bool
  142. * @since 7.0.0
  143. */
  144. public function isEncrypted();
  145. /**
  146. * Get the permissions of the file or folder as bitmasked combination of the following constants
  147. * \OCP\Constants::PERMISSION_CREATE
  148. * \OCP\Constants::PERMISSION_READ
  149. * \OCP\Constants::PERMISSION_UPDATE
  150. * \OCP\Constants::PERMISSION_DELETE
  151. * \OCP\Constants::PERMISSION_SHARE
  152. * \OCP\Constants::PERMISSION_ALL
  153. *
  154. * @return int
  155. * @since 7.0.0 - namespace of constants has changed in 8.0.0
  156. */
  157. public function getPermissions();
  158. /**
  159. * Check whether this is a file or a folder
  160. *
  161. * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
  162. * @since 7.0.0
  163. */
  164. public function getType();
  165. /**
  166. * Check if the file or folder is readable
  167. *
  168. * @return bool
  169. * @since 7.0.0
  170. */
  171. public function isReadable();
  172. /**
  173. * Check if a file is writable
  174. *
  175. * @return bool
  176. * @since 7.0.0
  177. */
  178. public function isUpdateable();
  179. /**
  180. * Check whether new files or folders can be created inside this folder
  181. *
  182. * @return bool
  183. * @since 8.0.0
  184. */
  185. public function isCreatable();
  186. /**
  187. * Check if a file or folder can be deleted
  188. *
  189. * @return bool
  190. * @since 7.0.0
  191. */
  192. public function isDeletable();
  193. /**
  194. * Check if a file or folder can be shared
  195. *
  196. * @return bool
  197. * @since 7.0.0
  198. */
  199. public function isShareable();
  200. /**
  201. * Check if a file or folder is shared
  202. *
  203. * @return bool
  204. * @since 7.0.0
  205. */
  206. public function isShared();
  207. /**
  208. * Check if a file or folder is mounted
  209. *
  210. * @return bool
  211. * @since 7.0.0
  212. */
  213. public function isMounted();
  214. /**
  215. * Get the mountpoint the file belongs to
  216. *
  217. * @return \OCP\Files\Mount\IMountPoint
  218. * @since 8.0.0
  219. */
  220. public function getMountPoint();
  221. /**
  222. * Get the owner of the file
  223. *
  224. * @return \OCP\IUser
  225. * @since 9.0.0
  226. */
  227. public function getOwner();
  228. /**
  229. * Get the stored checksum for this file
  230. *
  231. * @return string
  232. * @since 9.0.0
  233. */
  234. public function getChecksum();
  235. }