SimpleFile.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
  4. *
  5. * @author Roeland Jago Douma <roeland@famdouma.nl>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OC\Files\SimpleFS;
  24. use OCP\Files\File;
  25. use OCP\Files\NotPermittedException;
  26. use OCP\Files\SimpleFS\ISimpleFile;
  27. class SimpleFile implements ISimpleFile {
  28. /** @var File $file */
  29. private $file;
  30. /**
  31. * File constructor.
  32. *
  33. * @param File $file
  34. */
  35. public function __construct(File $file) {
  36. $this->file = $file;
  37. }
  38. /**
  39. * Get the name
  40. *
  41. * @return string
  42. */
  43. public function getName() {
  44. return $this->file->getName();
  45. }
  46. /**
  47. * Get the size in bytes
  48. *
  49. * @return int
  50. */
  51. public function getSize() {
  52. return $this->file->getSize();
  53. }
  54. /**
  55. * Get the ETag
  56. *
  57. * @return string
  58. */
  59. public function getETag() {
  60. return $this->file->getEtag();
  61. }
  62. /**
  63. * Get the last modification time
  64. *
  65. * @return int
  66. */
  67. public function getMTime() {
  68. return $this->file->getMTime();
  69. }
  70. /**
  71. * Get the content
  72. *
  73. * @return string
  74. */
  75. public function getContent() {
  76. return $this->file->getContent();
  77. }
  78. /**
  79. * Overwrite the file
  80. *
  81. * @param string $data
  82. * @throws NotPermittedException
  83. */
  84. public function putContent($data) {
  85. $this->file->putContent($data);
  86. }
  87. /**
  88. * Delete the file
  89. *
  90. * @throws NotPermittedException
  91. */
  92. public function delete() {
  93. $this->file->delete();
  94. }
  95. /**
  96. * Get the MimeType
  97. *
  98. * @return string
  99. */
  100. public function getMimeType() {
  101. return $this->file->getMimeType();
  102. }
  103. }