FileInfo.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. * @param bool $includeMounts whether or not to include the size of any sub mounts, since 16.0.0
  79. * @return int
  80. * @since 7.0.0
  81. */
  82. public function getSize($includeMounts = true);
  83. /**
  84. * Get the last modified date as timestamp for the file or folder
  85. *
  86. * @return int
  87. * @since 7.0.0
  88. */
  89. public function getMtime();
  90. /**
  91. * Get the name of the file or folder
  92. *
  93. * @return string
  94. * @since 7.0.0
  95. */
  96. public function getName();
  97. /**
  98. * Get the path relative to the storage
  99. *
  100. * @return string
  101. * @since 7.0.0
  102. */
  103. public function getInternalPath();
  104. /**
  105. * Get the absolute path
  106. *
  107. * @return string
  108. * @since 7.0.0
  109. */
  110. public function getPath();
  111. /**
  112. * Get the full mimetype of the file or folder i.e. 'image/png'
  113. *
  114. * @return string
  115. * @since 7.0.0
  116. */
  117. public function getMimetype();
  118. /**
  119. * Get the first part of the mimetype of the file or folder i.e. 'image'
  120. *
  121. * @return string
  122. * @since 7.0.0
  123. */
  124. public function getMimePart();
  125. /**
  126. * Get the storage the file or folder is storage on
  127. *
  128. * @return \OCP\Files\Storage
  129. * @since 7.0.0
  130. */
  131. public function getStorage();
  132. /**
  133. * Get the file id of the file or folder
  134. *
  135. * @return int|null
  136. * @since 7.0.0
  137. */
  138. public function getId();
  139. /**
  140. * Check whether the file is encrypted
  141. *
  142. * @return bool
  143. * @since 7.0.0
  144. */
  145. public function isEncrypted();
  146. /**
  147. * Get the permissions of the file or folder as bitmasked combination of the following constants
  148. * \OCP\Constants::PERMISSION_CREATE
  149. * \OCP\Constants::PERMISSION_READ
  150. * \OCP\Constants::PERMISSION_UPDATE
  151. * \OCP\Constants::PERMISSION_DELETE
  152. * \OCP\Constants::PERMISSION_SHARE
  153. * \OCP\Constants::PERMISSION_ALL
  154. *
  155. * @return int
  156. * @since 7.0.0 - namespace of constants has changed in 8.0.0
  157. */
  158. public function getPermissions();
  159. /**
  160. * Check whether this is a file or a folder
  161. *
  162. * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
  163. * @since 7.0.0
  164. */
  165. public function getType();
  166. /**
  167. * Check if the file or folder is readable
  168. *
  169. * @return bool
  170. * @since 7.0.0
  171. */
  172. public function isReadable();
  173. /**
  174. * Check if a file is writable
  175. *
  176. * @return bool
  177. * @since 7.0.0
  178. */
  179. public function isUpdateable();
  180. /**
  181. * Check whether new files or folders can be created inside this folder
  182. *
  183. * @return bool
  184. * @since 8.0.0
  185. */
  186. public function isCreatable();
  187. /**
  188. * Check if a file or folder can be deleted
  189. *
  190. * @return bool
  191. * @since 7.0.0
  192. */
  193. public function isDeletable();
  194. /**
  195. * Check if a file or folder can be shared
  196. *
  197. * @return bool
  198. * @since 7.0.0
  199. */
  200. public function isShareable();
  201. /**
  202. * Check if a file or folder is shared
  203. *
  204. * @return bool
  205. * @since 7.0.0
  206. */
  207. public function isShared();
  208. /**
  209. * Check if a file or folder is mounted
  210. *
  211. * @return bool
  212. * @since 7.0.0
  213. */
  214. public function isMounted();
  215. /**
  216. * Get the mountpoint the file belongs to
  217. *
  218. * @return \OCP\Files\Mount\IMountPoint
  219. * @since 8.0.0
  220. */
  221. public function getMountPoint();
  222. /**
  223. * Get the owner of the file
  224. *
  225. * @return \OCP\IUser
  226. * @since 9.0.0
  227. */
  228. public function getOwner();
  229. /**
  230. * Get the stored checksum for this file
  231. *
  232. * @return string
  233. * @since 9.0.0
  234. */
  235. public function getChecksum();
  236. /**
  237. * Get the extension of the file
  238. *
  239. * @return string
  240. * @since 15.0.0
  241. */
  242. public function getExtension(): string;
  243. /**
  244. * Get the creation date as unix timestamp
  245. *
  246. * If the creation time is not known, 0 will be returned
  247. *
  248. * creation time is not set automatically by the server and is generally only available
  249. * for files uploaded by the sync clients
  250. *
  251. * @return int
  252. * @since 18.0.0
  253. */
  254. public function getCreationTime(): int;
  255. /**
  256. * Get the upload date as unix timestamp
  257. *
  258. * If the upload time is not known, 0 will be returned
  259. *
  260. * Upload time will be set automatically by the server for files uploaded over DAV
  261. * files created by Nextcloud apps generally do not have an the upload time set
  262. *
  263. * @return int
  264. * @since 18.0.0
  265. */
  266. public function getUploadTime(): int;
  267. }