截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FilesystemInterface.php 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?php
  2. namespace League\Flysystem;
  3. use InvalidArgumentException;
  4. interface FilesystemInterface
  5. {
  6. /**
  7. * Check whether a file exists.
  8. *
  9. * @param string $path
  10. *
  11. * @return bool
  12. */
  13. public function has($path);
  14. /**
  15. * Read a file.
  16. *
  17. * @param string $path The path to the file.
  18. *
  19. * @throws FileNotFoundException
  20. *
  21. * @return string|false The file contents or false on failure.
  22. */
  23. public function read($path);
  24. /**
  25. * Retrieves a read-stream for a path.
  26. *
  27. * @param string $path The path to the file.
  28. *
  29. * @throws FileNotFoundException
  30. *
  31. * @return resource|false The path resource or false on failure.
  32. */
  33. public function readStream($path);
  34. /**
  35. * List contents of a directory.
  36. *
  37. * @param string $directory The directory to list.
  38. * @param bool $recursive Whether to list recursively.
  39. *
  40. * @return array A list of file metadata.
  41. */
  42. public function listContents($directory = '', $recursive = false);
  43. /**
  44. * Get a file's metadata.
  45. *
  46. * @param string $path The path to the file.
  47. *
  48. * @throws FileNotFoundException
  49. *
  50. * @return array|false The file metadata or false on failure.
  51. */
  52. public function getMetadata($path);
  53. /**
  54. * Get a file's size.
  55. *
  56. * @param string $path The path to the file.
  57. *
  58. * @throws FileNotFoundException
  59. *
  60. * @return int|false The file size or false on failure.
  61. */
  62. public function getSize($path);
  63. /**
  64. * Get a file's mime-type.
  65. *
  66. * @param string $path The path to the file.
  67. *
  68. * @throws FileNotFoundException
  69. *
  70. * @return string|false The file mime-type or false on failure.
  71. */
  72. public function getMimetype($path);
  73. /**
  74. * Get a file's timestamp.
  75. *
  76. * @param string $path The path to the file.
  77. *
  78. * @throws FileNotFoundException
  79. *
  80. * @return int|false The timestamp or false on failure.
  81. */
  82. public function getTimestamp($path);
  83. /**
  84. * Get a file's visibility.
  85. *
  86. * @param string $path The path to the file.
  87. *
  88. * @throws FileNotFoundException
  89. *
  90. * @return string|false The visibility (public|private) or false on failure.
  91. */
  92. public function getVisibility($path);
  93. /**
  94. * Write a new file.
  95. *
  96. * @param string $path The path of the new file.
  97. * @param string $contents The file contents.
  98. * @param array $config An optional configuration array.
  99. *
  100. * @throws FileExistsException
  101. *
  102. * @return bool True on success, false on failure.
  103. */
  104. public function write($path, $contents, array $config = []);
  105. /**
  106. * Write a new file using a stream.
  107. *
  108. * @param string $path The path of the new file.
  109. * @param resource $resource The file handle.
  110. * @param array $config An optional configuration array.
  111. *
  112. * @throws InvalidArgumentException If $resource is not a file handle.
  113. * @throws FileExistsException
  114. *
  115. * @return bool True on success, false on failure.
  116. */
  117. public function writeStream($path, $resource, array $config = []);
  118. /**
  119. * Update an existing file.
  120. *
  121. * @param string $path The path of the existing file.
  122. * @param string $contents The file contents.
  123. * @param array $config An optional configuration array.
  124. *
  125. * @throws FileNotFoundException
  126. *
  127. * @return bool True on success, false on failure.
  128. */
  129. public function update($path, $contents, array $config = []);
  130. /**
  131. * Update an existing file using a stream.
  132. *
  133. * @param string $path The path of the existing file.
  134. * @param resource $resource The file handle.
  135. * @param array $config An optional configuration array.
  136. *
  137. * @throws InvalidArgumentException If $resource is not a file handle.
  138. * @throws FileNotFoundException
  139. *
  140. * @return bool True on success, false on failure.
  141. */
  142. public function updateStream($path, $resource, array $config = []);
  143. /**
  144. * Rename a file.
  145. *
  146. * @param string $path Path to the existing file.
  147. * @param string $newpath The new path of the file.
  148. *
  149. * @throws FileExistsException Thrown if $newpath exists.
  150. * @throws FileNotFoundException Thrown if $path does not exist.
  151. *
  152. * @return bool True on success, false on failure.
  153. */
  154. public function rename($path, $newpath);
  155. /**
  156. * Copy a file.
  157. *
  158. * @param string $path Path to the existing file.
  159. * @param string $newpath The new path of the file.
  160. *
  161. * @throws FileExistsException Thrown if $newpath exists.
  162. * @throws FileNotFoundException Thrown if $path does not exist.
  163. *
  164. * @return bool True on success, false on failure.
  165. */
  166. public function copy($path, $newpath);
  167. /**
  168. * Delete a file.
  169. *
  170. * @param string $path
  171. *
  172. * @throws FileNotFoundException
  173. *
  174. * @return bool True on success, false on failure.
  175. */
  176. public function delete($path);
  177. /**
  178. * Delete a directory.
  179. *
  180. * @param string $dirname
  181. *
  182. * @throws RootViolationException Thrown if $dirname is empty.
  183. *
  184. * @return bool True on success, false on failure.
  185. */
  186. public function deleteDir($dirname);
  187. /**
  188. * Create a directory.
  189. *
  190. * @param string $dirname The name of the new directory.
  191. * @param array $config An optional configuration array.
  192. *
  193. * @return bool True on success, false on failure.
  194. */
  195. public function createDir($dirname, array $config = []);
  196. /**
  197. * Set the visibility for a file.
  198. *
  199. * @param string $path The path to the file.
  200. * @param string $visibility One of 'public' or 'private'.
  201. *
  202. * @throws FileNotFoundException
  203. *
  204. * @return bool True on success, false on failure.
  205. */
  206. public function setVisibility($path, $visibility);
  207. /**
  208. * Create a file or update if exists.
  209. *
  210. * @param string $path The path to the file.
  211. * @param string $contents The file contents.
  212. * @param array $config An optional configuration array.
  213. *
  214. * @return bool True on success, false on failure.
  215. */
  216. public function put($path, $contents, array $config = []);
  217. /**
  218. * Create a file or update if exists.
  219. *
  220. * @param string $path The path to the file.
  221. * @param resource $resource The file handle.
  222. * @param array $config An optional configuration array.
  223. *
  224. * @throws InvalidArgumentException Thrown if $resource is not a resource.
  225. *
  226. * @return bool True on success, false on failure.
  227. */
  228. public function putStream($path, $resource, array $config = []);
  229. /**
  230. * Read and delete a file.
  231. *
  232. * @param string $path The path to the file.
  233. *
  234. * @throws FileNotFoundException
  235. *
  236. * @return string|false The file contents, or false on failure.
  237. */
  238. public function readAndDelete($path);
  239. /**
  240. * Get a file/directory handler.
  241. *
  242. * @deprecated
  243. *
  244. * @param string $path The path to the file.
  245. * @param Handler $handler An optional existing handler to populate.
  246. *
  247. * @return Handler Either a file or directory handler.
  248. */
  249. public function get($path, Handler $handler = null);
  250. /**
  251. * Register a plugin.
  252. *
  253. * @param PluginInterface $plugin The plugin to register.
  254. *
  255. * @return $this
  256. */
  257. public function addPlugin(PluginInterface $plugin);
  258. }