ReadInterface.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\ReadInterface
  9. * @api
  10. * @since 100.0.2
  11. */
  12. interface ReadInterface
  13. {
  14. /**
  15. * Get absolute path
  16. *
  17. * @param string $path [optional]
  18. * @return string
  19. */
  20. public function getAbsolutePath($path = null);
  21. /**
  22. * Get relative path
  23. *
  24. * @param string $path
  25. * @return string
  26. */
  27. public function getRelativePath($path = null);
  28. /**
  29. * Retrieve list of all entities in given path
  30. *
  31. * @param string $path [optional]
  32. * @return array
  33. */
  34. public function read($path = null);
  35. /**
  36. * Search all entries for given regex pattern
  37. *
  38. * @param string $pattern
  39. * @param string $path [optional]
  40. * @return array
  41. */
  42. public function search($pattern, $path = null);
  43. /**
  44. * Check a file or directory exists
  45. *
  46. * @param string $path [optional]
  47. * @return bool
  48. */
  49. public function isExist($path = null);
  50. /**
  51. * Gathers the statistics of the given path
  52. *
  53. * @param string $path
  54. * @return array
  55. */
  56. public function stat($path);
  57. /**
  58. * Check permissions for reading file or directory
  59. *
  60. * @param string $path [optional]
  61. * @return bool
  62. */
  63. public function isReadable($path = null);
  64. /**
  65. * Check whether given path is file
  66. *
  67. * @param string $path
  68. * @return bool
  69. */
  70. public function isFile($path);
  71. /**
  72. * Check whether given path is directory
  73. *
  74. * @param string $path [optional]
  75. * @return bool
  76. */
  77. public function isDirectory($path = null);
  78. /**
  79. * Open file in read mode
  80. *
  81. * @param string $path
  82. * @return \Magento\Framework\Filesystem\File\ReadInterface
  83. * @throws \Magento\Framework\Exception\FileSystemException
  84. */
  85. public function openFile($path);
  86. /**
  87. * Retrieve file contents from given path
  88. *
  89. * @param string $path
  90. * @param string|null $flag
  91. * @param resource|null $context
  92. * @return string
  93. * @throws \Magento\Framework\Exception\FileSystemException
  94. */
  95. public function readFile($path, $flag = null, $context = null);
  96. }