FileInfo.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Files;
  8. use OCP\Files\Storage\IStorage;
  9. /**
  10. * Interface FileInfo
  11. *
  12. * @since 7.0.0
  13. */
  14. interface FileInfo {
  15. /**
  16. * @since 7.0.0
  17. */
  18. public const TYPE_FILE = 'file';
  19. /**
  20. * @since 7.0.0
  21. */
  22. public const TYPE_FOLDER = 'dir';
  23. /**
  24. * @const \OCP\Files\FileInfo::SPACE_NOT_COMPUTED Return value for a not computed space value
  25. * @since 8.0.0
  26. */
  27. public const SPACE_NOT_COMPUTED = -1;
  28. /**
  29. * @const \OCP\Files\FileInfo::SPACE_UNKNOWN Return value for unknown space value
  30. * @since 8.0.0
  31. */
  32. public const SPACE_UNKNOWN = -2;
  33. /**
  34. * @const \OCP\Files\FileInfo::SPACE_UNLIMITED Return value for unlimited space
  35. * @since 8.0.0
  36. */
  37. public const SPACE_UNLIMITED = -3;
  38. /**
  39. * @since 9.1.0
  40. */
  41. public const MIMETYPE_FOLDER = 'httpd/unix-directory';
  42. /**
  43. * @const \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX Return regular expression to test filenames against (blacklisting)
  44. * @since 12.0.0
  45. */
  46. public const BLACKLIST_FILES_REGEX = '\.(part|filepart)$';
  47. /**
  48. * Get the Etag of the file or folder
  49. *
  50. * @return string
  51. * @since 7.0.0
  52. */
  53. public function getEtag();
  54. /**
  55. * Get the size in bytes for the file or folder
  56. *
  57. * @param bool $includeMounts whether or not to include the size of any sub mounts, since 16.0.0
  58. * @return int|float
  59. * @since 7.0.0
  60. */
  61. public function getSize($includeMounts = true);
  62. /**
  63. * Get the last modified date as timestamp for the file or folder
  64. *
  65. * @return int
  66. * @since 7.0.0
  67. */
  68. public function getMtime();
  69. /**
  70. * Get the name of the file or folder
  71. *
  72. * @return string
  73. * @since 7.0.0
  74. */
  75. public function getName();
  76. /**
  77. * Get the path relative to the storage
  78. *
  79. * @return string
  80. * @since 7.0.0
  81. */
  82. public function getInternalPath();
  83. /**
  84. * Get the absolute path
  85. *
  86. * @return string
  87. * @since 7.0.0
  88. */
  89. public function getPath();
  90. /**
  91. * Get the full mimetype of the file or folder i.e. 'image/png'
  92. *
  93. * @return string
  94. * @since 7.0.0
  95. */
  96. public function getMimetype();
  97. /**
  98. * Get the first part of the mimetype of the file or folder i.e. 'image'
  99. *
  100. * @return string
  101. * @since 7.0.0
  102. */
  103. public function getMimePart();
  104. /**
  105. * Get the storage the file or folder is storage on
  106. *
  107. * @return IStorage
  108. * @since 7.0.0
  109. */
  110. public function getStorage();
  111. /**
  112. * Get the file id of the file or folder
  113. *
  114. * @return int|null
  115. * @since 7.0.0
  116. */
  117. public function getId();
  118. /**
  119. * Check whether the file is encrypted
  120. *
  121. * @return bool
  122. * @since 7.0.0
  123. */
  124. public function isEncrypted();
  125. /**
  126. * Get the permissions of the file or folder as bitmasked combination of the following constants
  127. * \OCP\Constants::PERMISSION_CREATE
  128. * \OCP\Constants::PERMISSION_READ
  129. * \OCP\Constants::PERMISSION_UPDATE
  130. * \OCP\Constants::PERMISSION_DELETE
  131. * \OCP\Constants::PERMISSION_SHARE
  132. * \OCP\Constants::PERMISSION_ALL
  133. *
  134. * @return int
  135. * @since 7.0.0 - namespace of constants has changed in 8.0.0
  136. */
  137. public function getPermissions();
  138. /**
  139. * Check whether this is a file or a folder
  140. *
  141. * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
  142. * @since 7.0.0
  143. */
  144. public function getType();
  145. /**
  146. * Check if the file or folder is readable
  147. *
  148. * @return bool
  149. * @since 7.0.0
  150. */
  151. public function isReadable();
  152. /**
  153. * Check if a file is writable
  154. *
  155. * @return bool
  156. * @since 7.0.0
  157. */
  158. public function isUpdateable();
  159. /**
  160. * Check whether new files or folders can be created inside this folder
  161. *
  162. * @return bool
  163. * @since 8.0.0
  164. */
  165. public function isCreatable();
  166. /**
  167. * Check if a file or folder can be deleted
  168. *
  169. * @return bool
  170. * @since 7.0.0
  171. */
  172. public function isDeletable();
  173. /**
  174. * Check if a file or folder can be shared
  175. *
  176. * @return bool
  177. * @since 7.0.0
  178. */
  179. public function isShareable();
  180. /**
  181. * Check if a file or folder is shared
  182. *
  183. * @return bool
  184. * @since 7.0.0
  185. */
  186. public function isShared();
  187. /**
  188. * Check if a file or folder is mounted
  189. *
  190. * @return bool
  191. * @since 7.0.0
  192. */
  193. public function isMounted();
  194. /**
  195. * Get the mountpoint the file belongs to
  196. *
  197. * @return \OCP\Files\Mount\IMountPoint
  198. * @since 8.0.0
  199. */
  200. public function getMountPoint();
  201. /**
  202. * Get the owner of the file
  203. *
  204. * @return ?\OCP\IUser
  205. * @since 9.0.0
  206. */
  207. public function getOwner();
  208. /**
  209. * Get the stored checksum(s) for this file
  210. *
  211. * Checksums are stored in the format TYPE:CHECKSUM, here may be multiple checksums separated by a single space
  212. * e.g. MD5:d3b07384d113edec49eaa6238ad5ff00 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
  213. *
  214. * @return string
  215. * @since 9.0.0
  216. */
  217. public function getChecksum();
  218. /**
  219. * Get the extension of the file
  220. *
  221. * @return string
  222. * @since 15.0.0
  223. */
  224. public function getExtension(): string;
  225. /**
  226. * Get the creation date as unix timestamp
  227. *
  228. * If the creation time is not known, 0 will be returned
  229. *
  230. * creation time is not set automatically by the server and is generally only available
  231. * for files uploaded by the sync clients
  232. *
  233. * @return int
  234. * @since 18.0.0
  235. */
  236. public function getCreationTime(): int;
  237. /**
  238. * Get the upload date as unix timestamp
  239. *
  240. * If the upload time is not known, 0 will be returned
  241. *
  242. * Upload time will be set automatically by the server for files uploaded over DAV
  243. * files created by Nextcloud apps generally do not have an the upload time set
  244. *
  245. * @return int
  246. * @since 18.0.0
  247. */
  248. public function getUploadTime(): int;
  249. /**
  250. * Get the fileid or the parent folder
  251. * or -1 if this item has no parent folder (because it is the root)
  252. *
  253. * @return int
  254. * @since 28.0.0
  255. */
  256. public function getParentId(): int;
  257. /**
  258. * Get the metadata, if available
  259. *
  260. * @return array<string, int|string|bool|float|string[]|int[]>
  261. * @since 28.0.0
  262. */
  263. public function getMetadata(): array;
  264. }