FileInfo.php 6.4 KB

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