Filesystem.php 4.0 KB

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