1
0

FileInfo.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 node is encrypted.
  120. * If it is a file, then it is server side encrypted.
  121. * If it is a folder, then it is end-to-end encrypted.
  122. *
  123. * @return bool
  124. * @since 7.0.0
  125. */
  126. public function isEncrypted();
  127. /**
  128. * Get the permissions of the file or folder as bitmasked combination of the following constants
  129. * \OCP\Constants::PERMISSION_CREATE
  130. * \OCP\Constants::PERMISSION_READ
  131. * \OCP\Constants::PERMISSION_UPDATE
  132. * \OCP\Constants::PERMISSION_DELETE
  133. * \OCP\Constants::PERMISSION_SHARE
  134. * \OCP\Constants::PERMISSION_ALL
  135. *
  136. * @return int
  137. * @since 7.0.0 - namespace of constants has changed in 8.0.0
  138. */
  139. public function getPermissions();
  140. /**
  141. * Check whether this is a file or a folder
  142. *
  143. * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
  144. * @since 7.0.0
  145. */
  146. public function getType();
  147. /**
  148. * Check if the file or folder is readable
  149. *
  150. * @return bool
  151. * @since 7.0.0
  152. */
  153. public function isReadable();
  154. /**
  155. * Check if a file is writable
  156. *
  157. * @return bool
  158. * @since 7.0.0
  159. */
  160. public function isUpdateable();
  161. /**
  162. * Check whether new files or folders can be created inside this folder
  163. *
  164. * @return bool
  165. * @since 8.0.0
  166. */
  167. public function isCreatable();
  168. /**
  169. * Check if a file or folder can be deleted
  170. *
  171. * @return bool
  172. * @since 7.0.0
  173. */
  174. public function isDeletable();
  175. /**
  176. * Check if a file or folder can be shared
  177. *
  178. * @return bool
  179. * @since 7.0.0
  180. */
  181. public function isShareable();
  182. /**
  183. * Check if a file or folder is shared
  184. *
  185. * @return bool
  186. * @since 7.0.0
  187. */
  188. public function isShared();
  189. /**
  190. * Check if a file or folder is mounted
  191. *
  192. * @return bool
  193. * @since 7.0.0
  194. */
  195. public function isMounted();
  196. /**
  197. * Get the mountpoint the file belongs to
  198. *
  199. * @return \OCP\Files\Mount\IMountPoint
  200. * @since 8.0.0
  201. */
  202. public function getMountPoint();
  203. /**
  204. * Get the owner of the file
  205. *
  206. * @return ?\OCP\IUser
  207. * @since 9.0.0
  208. */
  209. public function getOwner();
  210. /**
  211. * Get the stored checksum(s) for this file
  212. *
  213. * Checksums are stored in the format TYPE:CHECKSUM, here may be multiple checksums separated by a single space
  214. * e.g. MD5:d3b07384d113edec49eaa6238ad5ff00 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
  215. *
  216. * @return string
  217. * @since 9.0.0
  218. */
  219. public function getChecksum();
  220. /**
  221. * Get the extension of the file
  222. *
  223. * @return string
  224. * @since 15.0.0
  225. */
  226. public function getExtension(): string;
  227. /**
  228. * Get the creation date as unix timestamp
  229. *
  230. * If the creation time is not known, 0 will be returned
  231. *
  232. * creation time is not set automatically by the server and is generally only available
  233. * for files uploaded by the sync clients
  234. *
  235. * @return int
  236. * @since 18.0.0
  237. */
  238. public function getCreationTime(): int;
  239. /**
  240. * Get the upload date as unix timestamp
  241. *
  242. * If the upload time is not known, 0 will be returned
  243. *
  244. * Upload time will be set automatically by the server for files uploaded over DAV
  245. * files created by Nextcloud apps generally do not have an the upload time set
  246. *
  247. * @return int
  248. * @since 18.0.0
  249. */
  250. public function getUploadTime(): int;
  251. /**
  252. * Get the fileid or the parent folder
  253. * or -1 if this item has no parent folder (because it is the root)
  254. *
  255. * @return int
  256. * @since 28.0.0
  257. */
  258. public function getParentId(): int;
  259. /**
  260. * Get the metadata, if available
  261. *
  262. * @return array<string, int|string|bool|float|string[]|int[]>
  263. * @since 28.0.0
  264. */
  265. public function getMetadata(): array;
  266. }