Filesystem.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. namespace Illuminate\Contracts\Filesystem;
  3. interface Filesystem
  4. {
  5. /**
  6. * The public visibility setting.
  7. *
  8. * @var string
  9. */
  10. const VISIBILITY_PUBLIC = 'public';
  11. /**
  12. * The private visibility setting.
  13. *
  14. * @var string
  15. */
  16. const VISIBILITY_PRIVATE = 'private';
  17. /**
  18. * Determine if a file exists.
  19. *
  20. * @param string $path
  21. * @return bool
  22. */
  23. public function exists($path);
  24. /**
  25. * Get the contents of a file.
  26. *
  27. * @param string $path
  28. * @return string
  29. *
  30. * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  31. */
  32. public function get($path);
  33. /**
  34. * Get a resource to read the file.
  35. *
  36. * @param string $path
  37. * @return resource|null The path resource or null on failure.
  38. *
  39. * @throws FileNotFoundException
  40. */
  41. public function readStream($path);
  42. /**
  43. * Write the contents of a file.
  44. *
  45. * @param string $path
  46. * @param string|resource $contents
  47. * @param mixed $options
  48. * @return bool
  49. */
  50. public function put($path, $contents, $options = []);
  51. /**
  52. * Write a new file using a stream.
  53. *
  54. * @param string $path
  55. * @param resource $resource
  56. * @param array $options
  57. * @return bool
  58. *
  59. * @throws \InvalidArgumentException If $resource is not a file handle.
  60. * @throws FileExistsException
  61. */
  62. public function writeStream($path, $resource, array $options = []);
  63. /**
  64. * Get the visibility for the given path.
  65. *
  66. * @param string $path
  67. * @return string
  68. */
  69. public function getVisibility($path);
  70. /**
  71. * Set the visibility for the given path.
  72. *
  73. * @param string $path
  74. * @param string $visibility
  75. * @return bool
  76. */
  77. public function setVisibility($path, $visibility);
  78. /**
  79. * Prepend to a file.
  80. *
  81. * @param string $path
  82. * @param string $data
  83. * @return bool
  84. */
  85. public function prepend($path, $data);
  86. /**
  87. * Append to a file.
  88. *
  89. * @param string $path
  90. * @param string $data
  91. * @return bool
  92. */
  93. public function append($path, $data);
  94. /**
  95. * Delete the file at a given path.
  96. *
  97. * @param string|array $paths
  98. * @return bool
  99. */
  100. public function delete($paths);
  101. /**
  102. * Copy a file to a new location.
  103. *
  104. * @param string $from
  105. * @param string $to
  106. * @return bool
  107. */
  108. public function copy($from, $to);
  109. /**
  110. * Move a file to a new location.
  111. *
  112. * @param string $from
  113. * @param string $to
  114. * @return bool
  115. */
  116. public function move($from, $to);
  117. /**
  118. * Get the file size of a given file.
  119. *
  120. * @param string $path
  121. * @return int
  122. */
  123. public function size($path);
  124. /**
  125. * Get the file's last modification time.
  126. *
  127. * @param string $path
  128. * @return int
  129. */
  130. public function lastModified($path);
  131. /**
  132. * Get an array of all files in a directory.
  133. *
  134. * @param string|null $directory
  135. * @param bool $recursive
  136. * @return array
  137. */
  138. public function files($directory = null, $recursive = false);
  139. /**
  140. * Get all of the files from the given directory (recursive).
  141. *
  142. * @param string|null $directory
  143. * @return array
  144. */
  145. public function allFiles($directory = null);
  146. /**
  147. * Get all of the directories within a given directory.
  148. *
  149. * @param string|null $directory
  150. * @param bool $recursive
  151. * @return array
  152. */
  153. public function directories($directory = null, $recursive = false);
  154. /**
  155. * Get all (recursive) of the directories within a given directory.
  156. *
  157. * @param string|null $directory
  158. * @return array
  159. */
  160. public function allDirectories($directory = null);
  161. /**
  162. * Create a directory.
  163. *
  164. * @param string $path
  165. * @return bool
  166. */
  167. public function makeDirectory($path);
  168. /**
  169. * Recursively delete a directory.
  170. *
  171. * @param string $directory
  172. * @return bool
  173. */
  174. public function deleteDirectory($directory);
  175. }