ISimpleFile.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Julius Härtl <jus@bitgrid.net>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCP\Files\SimpleFS;
  26. use OCP\Files\NotFoundException;
  27. use OCP\Files\NotPermittedException;
  28. /**
  29. * This interface allows to manage simple files.
  30. *
  31. * This interface must not be implemented in your application but
  32. * instead should be used as a service and injected in your code with
  33. * dependency injection.
  34. *
  35. * @since 11.0.0
  36. */
  37. interface ISimpleFile {
  38. /**
  39. * Get the name
  40. *
  41. * @since 11.0.0
  42. */
  43. public function getName(): string;
  44. /**
  45. * Get the size in bytes
  46. *
  47. * @since 11.0.0
  48. */
  49. public function getSize(): int|float;
  50. /**
  51. * Get the ETag
  52. *
  53. * @since 11.0.0
  54. */
  55. public function getETag(): string;
  56. /**
  57. * Get the last modification time
  58. *
  59. * @since 11.0.0
  60. */
  61. public function getMTime(): int;
  62. /**
  63. * Get the content
  64. *
  65. * @throws NotPermittedException
  66. * @throws NotFoundException
  67. * @since 11.0.0
  68. */
  69. public function getContent(): string;
  70. /**
  71. * Overwrite the file
  72. *
  73. * @param string|resource $data
  74. * @throws NotPermittedException
  75. * @throws NotFoundException
  76. * @since 11.0.0
  77. */
  78. public function putContent($data): void;
  79. /**
  80. * Delete the file
  81. *
  82. * @throws NotPermittedException
  83. * @since 11.0.0
  84. */
  85. public function delete(): void;
  86. /**
  87. * Get the MimeType
  88. *
  89. * @since 11.0.0
  90. */
  91. public function getMimeType(): string;
  92. /**
  93. * @since 24.0.0
  94. */
  95. public function getExtension(): string;
  96. /**
  97. * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
  98. *
  99. * @return resource|false
  100. * @throws \OCP\Files\NotPermittedException
  101. * @since 14.0.0
  102. */
  103. public function read();
  104. /**
  105. * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
  106. *
  107. * @return resource|bool
  108. * @throws \OCP\Files\NotPermittedException
  109. * @since 14.0.0
  110. */
  111. public function write();
  112. }