1
0

FileInfo.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Felix Heidecke <felix@heidecke.me>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Maxence Lange <maxence@artificial-owl.com>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin Appelman <robin@icewind.nl>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Thomas Müller <thomas.mueller@tmit.eu>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. namespace OCP\Files;
  31. use OCP\Files\Storage\IStorage;
  32. /**
  33. * Interface FileInfo
  34. *
  35. * @since 7.0.0
  36. */
  37. interface FileInfo {
  38. /**
  39. * @since 7.0.0
  40. */
  41. public const TYPE_FILE = 'file';
  42. /**
  43. * @since 7.0.0
  44. */
  45. public const TYPE_FOLDER = 'dir';
  46. /**
  47. * @const \OCP\Files\FileInfo::SPACE_NOT_COMPUTED Return value for a not computed space value
  48. * @since 8.0.0
  49. */
  50. public const SPACE_NOT_COMPUTED = -1;
  51. /**
  52. * @const \OCP\Files\FileInfo::SPACE_UNKNOWN Return value for unknown space value
  53. * @since 8.0.0
  54. */
  55. public const SPACE_UNKNOWN = -2;
  56. /**
  57. * @const \OCP\Files\FileInfo::SPACE_UNLIMITED Return value for unlimited space
  58. * @since 8.0.0
  59. */
  60. public const SPACE_UNLIMITED = -3;
  61. /**
  62. * @since 9.1.0
  63. */
  64. public const MIMETYPE_FOLDER = 'httpd/unix-directory';
  65. /**
  66. * @const \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX Return regular expression to test filenames against (blacklisting)
  67. * @since 12.0.0
  68. */
  69. public const BLACKLIST_FILES_REGEX = '\.(part|filepart)$';
  70. /**
  71. * Get the Etag of the file or folder
  72. *
  73. * @return string
  74. * @since 7.0.0
  75. */
  76. public function getEtag();
  77. /**
  78. * Get the size in bytes for the file or folder
  79. *
  80. * @param bool $includeMounts whether or not to include the size of any sub mounts, since 16.0.0
  81. * @return int|float
  82. * @since 7.0.0
  83. */
  84. public function getSize($includeMounts = true);
  85. /**
  86. * Get the last modified date as timestamp for the file or folder
  87. *
  88. * @return int
  89. * @since 7.0.0
  90. */
  91. public function getMtime();
  92. /**
  93. * Get the name of the file or folder
  94. *
  95. * @return string
  96. * @since 7.0.0
  97. */
  98. public function getName();
  99. /**
  100. * Get the path relative to the storage
  101. *
  102. * @return string
  103. * @since 7.0.0
  104. */
  105. public function getInternalPath();
  106. /**
  107. * Get the absolute path
  108. *
  109. * @return string
  110. * @since 7.0.0
  111. */
  112. public function getPath();
  113. /**
  114. * Get the full mimetype of the file or folder i.e. 'image/png'
  115. *
  116. * @return string
  117. * @since 7.0.0
  118. */
  119. public function getMimetype();
  120. /**
  121. * Get the first part of the mimetype of the file or folder i.e. 'image'
  122. *
  123. * @return string
  124. * @since 7.0.0
  125. */
  126. public function getMimePart();
  127. /**
  128. * Get the storage the file or folder is storage on
  129. *
  130. * @return IStorage
  131. * @since 7.0.0
  132. */
  133. public function getStorage();
  134. /**
  135. * Get the file id of the file or folder
  136. *
  137. * @return int|null
  138. * @since 7.0.0
  139. */
  140. public function getId();
  141. /**
  142. * Check whether the file is encrypted
  143. *
  144. * @return bool
  145. * @since 7.0.0
  146. */
  147. public function isEncrypted();
  148. /**
  149. * Get the permissions of the file or folder as bitmasked combination of the following constants
  150. * \OCP\Constants::PERMISSION_CREATE
  151. * \OCP\Constants::PERMISSION_READ
  152. * \OCP\Constants::PERMISSION_UPDATE
  153. * \OCP\Constants::PERMISSION_DELETE
  154. * \OCP\Constants::PERMISSION_SHARE
  155. * \OCP\Constants::PERMISSION_ALL
  156. *
  157. * @return int
  158. * @since 7.0.0 - namespace of constants has changed in 8.0.0
  159. */
  160. public function getPermissions();
  161. /**
  162. * Check whether this is a file or a folder
  163. *
  164. * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
  165. * @since 7.0.0
  166. */
  167. public function getType();
  168. /**
  169. * Check if the file or folder is readable
  170. *
  171. * @return bool
  172. * @since 7.0.0
  173. */
  174. public function isReadable();
  175. /**
  176. * Check if a file is writable
  177. *
  178. * @return bool
  179. * @since 7.0.0
  180. */
  181. public function isUpdateable();
  182. /**
  183. * Check whether new files or folders can be created inside this folder
  184. *
  185. * @return bool
  186. * @since 8.0.0
  187. */
  188. public function isCreatable();
  189. /**
  190. * Check if a file or folder can be deleted
  191. *
  192. * @return bool
  193. * @since 7.0.0
  194. */
  195. public function isDeletable();
  196. /**
  197. * Check if a file or folder can be shared
  198. *
  199. * @return bool
  200. * @since 7.0.0
  201. */
  202. public function isShareable();
  203. /**
  204. * Check if a file or folder is shared
  205. *
  206. * @return bool
  207. * @since 7.0.0
  208. */
  209. public function isShared();
  210. /**
  211. * Check if a file or folder is mounted
  212. *
  213. * @return bool
  214. * @since 7.0.0
  215. */
  216. public function isMounted();
  217. /**
  218. * Get the mountpoint the file belongs to
  219. *
  220. * @return \OCP\Files\Mount\IMountPoint
  221. * @since 8.0.0
  222. */
  223. public function getMountPoint();
  224. /**
  225. * Get the owner of the file
  226. *
  227. * @return ?\OCP\IUser
  228. * @since 9.0.0
  229. */
  230. public function getOwner();
  231. /**
  232. * Get the stored checksum(s) for this file
  233. *
  234. * Checksums are stored in the format TYPE:CHECKSUM, here may be multiple checksums separated by a single space
  235. * e.g. MD5:d3b07384d113edec49eaa6238ad5ff00 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
  236. *
  237. * @return string
  238. * @since 9.0.0
  239. */
  240. public function getChecksum();
  241. /**
  242. * Get the extension of the file
  243. *
  244. * @return string
  245. * @since 15.0.0
  246. */
  247. public function getExtension(): string;
  248. /**
  249. * Get the creation date as unix timestamp
  250. *
  251. * If the creation time is not known, 0 will be returned
  252. *
  253. * creation time is not set automatically by the server and is generally only available
  254. * for files uploaded by the sync clients
  255. *
  256. * @return int
  257. * @since 18.0.0
  258. */
  259. public function getCreationTime(): int;
  260. /**
  261. * Get the upload date as unix timestamp
  262. *
  263. * If the upload time is not known, 0 will be returned
  264. *
  265. * Upload time will be set automatically by the server for files uploaded over DAV
  266. * files created by Nextcloud apps generally do not have an the upload time set
  267. *
  268. * @return int
  269. * @since 18.0.0
  270. */
  271. public function getUploadTime(): int;
  272. /**
  273. * Get the fileid or the parent folder
  274. * or -1 if this item has no parent folder (because it is the root)
  275. *
  276. * @return int
  277. * @since 28.0.0
  278. */
  279. public function getParentId(): int;
  280. /**
  281. * Get the metadata, if available
  282. *
  283. * @return array<string, int|string|bool|float|string[]|int[]>
  284. * @since 28.0.0
  285. */
  286. public function getMetadata(): array;
  287. }