Filesystem.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. * Get the full path to the file that exists at the given relative path.
  19. *
  20. * @param string $path
  21. * @return string
  22. */
  23. public function path($path);
  24. /**
  25. * Determine if a file exists.
  26. *
  27. * @param string $path
  28. * @return bool
  29. */
  30. public function exists($path);
  31. /**
  32. * Get the contents of a file.
  33. *
  34. * @param string $path
  35. * @return string|null
  36. */
  37. public function get($path);
  38. /**
  39. * Get a resource to read the file.
  40. *
  41. * @param string $path
  42. * @return resource|null The path resource or null on failure.
  43. */
  44. public function readStream($path);
  45. /**
  46. * Write the contents of a file.
  47. *
  48. * @param string $path
  49. * @param \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $contents
  50. * @param mixed $options
  51. * @return bool
  52. */
  53. public function put($path, $contents, $options = []);
  54. /**
  55. * Store the uploaded file on the disk.
  56. *
  57. * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $path
  58. * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|array|null $file
  59. * @param mixed $options
  60. * @return string|false
  61. */
  62. public function putFile($path, $file = null, $options = []);
  63. /**
  64. * Store the uploaded file on the disk with a given name.
  65. *
  66. * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $path
  67. * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|array|null $file
  68. * @param string|array|null $name
  69. * @param mixed $options
  70. * @return string|false
  71. */
  72. public function putFileAs($path, $file, $name = null, $options = []);
  73. /**
  74. * Write a new file using a stream.
  75. *
  76. * @param string $path
  77. * @param resource $resource
  78. * @param array $options
  79. * @return bool
  80. */
  81. public function writeStream($path, $resource, array $options = []);
  82. /**
  83. * Get the visibility for the given path.
  84. *
  85. * @param string $path
  86. * @return string
  87. */
  88. public function getVisibility($path);
  89. /**
  90. * Set the visibility for the given path.
  91. *
  92. * @param string $path
  93. * @param string $visibility
  94. * @return bool
  95. */
  96. public function setVisibility($path, $visibility);
  97. /**
  98. * Prepend to a file.
  99. *
  100. * @param string $path
  101. * @param string $data
  102. * @return bool
  103. */
  104. public function prepend($path, $data);
  105. /**
  106. * Append to a file.
  107. *
  108. * @param string $path
  109. * @param string $data
  110. * @return bool
  111. */
  112. public function append($path, $data);
  113. /**
  114. * Delete the file at a given path.
  115. *
  116. * @param string|array $paths
  117. * @return bool
  118. */
  119. public function delete($paths);
  120. /**
  121. * Copy a file to a new location.
  122. *
  123. * @param string $from
  124. * @param string $to
  125. * @return bool
  126. */
  127. public function copy($from, $to);
  128. /**
  129. * Move a file to a new location.
  130. *
  131. * @param string $from
  132. * @param string $to
  133. * @return bool
  134. */
  135. public function move($from, $to);
  136. /**
  137. * Get the file size of a given file.
  138. *
  139. * @param string $path
  140. * @return int
  141. */
  142. public function size($path);
  143. /**
  144. * Get the file's last modification time.
  145. *
  146. * @param string $path
  147. * @return int
  148. */
  149. public function lastModified($path);
  150. /**
  151. * Get an array of all files in a directory.
  152. *
  153. * @param string|null $directory
  154. * @param bool $recursive
  155. * @return array<string>
  156. */
  157. public function files($directory = null, $recursive = false);
  158. /**
  159. * Get all of the files from the given directory (recursive).
  160. *
  161. * @param string|null $directory
  162. * @return array<string>
  163. */
  164. public function allFiles($directory = null);
  165. /**
  166. * Get all of the directories within a given directory.
  167. *
  168. * @param string|null $directory
  169. * @param bool $recursive
  170. * @return array<string>
  171. */
  172. public function directories($directory = null, $recursive = false);
  173. /**
  174. * Get all (recursive) of the directories within a given directory.
  175. *
  176. * @param string|null $directory
  177. * @return array<string>
  178. */
  179. public function allDirectories($directory = null);
  180. /**
  181. * Create a directory.
  182. *
  183. * @param string $path
  184. * @return bool
  185. */
  186. public function makeDirectory($path);
  187. /**
  188. * Recursively delete a directory.
  189. *
  190. * @param string $directory
  191. * @return bool
  192. */
  193. public function deleteDirectory($directory);
  194. }