WriteInterface.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Filesystem\Directory;
  7. /**
  8. * Interface \Magento\Framework\Filesystem\Directory\WriteInterface
  9. * @api
  10. * @since 100.0.2
  11. */
  12. interface WriteInterface extends ReadInterface
  13. {
  14. /**
  15. * Create directory if it does not exists
  16. *
  17. * @param string $path [optional]
  18. * @return bool
  19. * @throws \Magento\Framework\Exception\FileSystemException
  20. */
  21. public function create($path = null);
  22. /**
  23. * Delete given path
  24. *
  25. * @param string $path [optional]
  26. * @return bool
  27. * @throws \Magento\Framework\Exception\FileSystemException
  28. */
  29. public function delete($path = null);
  30. /**
  31. * Rename a file
  32. *
  33. * @param string $path
  34. * @param string $newPath
  35. * @param WriteInterface $targetDirectory [optional]
  36. * @return bool
  37. * @throws \Magento\Framework\Exception\FileSystemException
  38. */
  39. public function renameFile($path, $newPath, WriteInterface $targetDirectory = null);
  40. /**
  41. * Copy a file
  42. *
  43. * @param string $path
  44. * @param string $destination
  45. * @param WriteInterface $targetDirectory [optional]
  46. * @return bool
  47. * @throws \Magento\Framework\Exception\FileSystemException
  48. */
  49. public function copyFile($path, $destination, WriteInterface $targetDirectory = null);
  50. /**
  51. * Creates symlink on a file or directory and places it to destination
  52. *
  53. * @param string $path
  54. * @param string $destination
  55. * @param WriteInterface $targetDirectory [optional]
  56. * @return bool
  57. * @throws \Magento\Framework\Exception\FileSystemException
  58. */
  59. public function createSymlink($path, $destination, WriteInterface $targetDirectory = null);
  60. /**
  61. * Change permissions of given path
  62. *
  63. * @param string $path
  64. * @param int $permissions
  65. * @return bool
  66. * @throws \Magento\Framework\Exception\FileSystemException
  67. */
  68. public function changePermissions($path, $permissions);
  69. /**
  70. * Change permissions of given path
  71. *
  72. * @param string $path
  73. * @param int $dirPermissions
  74. * @param int $filePermissions
  75. * @return bool
  76. * @throws \Magento\Framework\Exception\FileSystemException
  77. */
  78. public function changePermissionsRecursively($path, $dirPermissions, $filePermissions);
  79. /**
  80. * Sets access and modification time of file.
  81. *
  82. * @param string $path
  83. * @param int $modificationTime [optional]
  84. * @return bool
  85. * @throws \Magento\Framework\Exception\FileSystemException
  86. */
  87. public function touch($path, $modificationTime = null);
  88. /**
  89. * Check if given path is writable
  90. *
  91. * @param string $path [optional]
  92. * @return bool
  93. */
  94. public function isWritable($path = null);
  95. /**
  96. * Open file in given mode
  97. *
  98. * @param string $path
  99. * @param string $mode
  100. * @return \Magento\Framework\Filesystem\File\WriteInterface
  101. */
  102. public function openFile($path, $mode = 'w');
  103. /**
  104. * Open file in given path
  105. *
  106. * @param string $path
  107. * @param string $content
  108. * @param string $mode [optional]
  109. * @return int The number of bytes that were written.
  110. * @throws \Magento\Framework\Exception\FileSystemException
  111. */
  112. public function writeFile($path, $content, $mode = null);
  113. /**
  114. * Get driver
  115. *
  116. * @return \Magento\Framework\Filesystem\DriverInterface
  117. */
  118. public function getDriver();
  119. }