1 | <?php |
||
8 | class Filesystem implements FilesystemInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var MountManager |
||
12 | */ |
||
13 | private $manager; |
||
14 | |||
15 | /** |
||
16 | * Filesystem constructor. |
||
17 | * @param MountManager $manager |
||
18 | */ |
||
19 | 22 | public function __construct(MountManager $manager) |
|
23 | |||
24 | /** |
||
25 | * Check whether a file exists. |
||
26 | * |
||
27 | * @param string $path |
||
28 | * @return bool |
||
29 | */ |
||
30 | 1 | public function has($path) |
|
34 | |||
35 | /** |
||
36 | * Read a file. |
||
37 | * |
||
38 | * @param string $path The path to the file. |
||
39 | * @return string|false The file contents or false on failure. |
||
40 | */ |
||
41 | 1 | public function read($path) |
|
45 | |||
46 | /** |
||
47 | * Retrieves a read-stream for a path. |
||
48 | * |
||
49 | * @param string $path The path to the file. |
||
50 | * @return resource|false The path resource or false on failure. |
||
51 | */ |
||
52 | 1 | public function readStream($path) |
|
56 | |||
57 | /** |
||
58 | * List contents of a directory. |
||
59 | * |
||
60 | * @param string $directory The directory to list. |
||
61 | * @param bool $recursive Whether to list recursively. |
||
62 | * @return array A list of file metadata. |
||
63 | */ |
||
64 | 1 | public function listContents($directory = '', $recursive = false) |
|
68 | |||
69 | /** |
||
70 | * Get a file's metadata. |
||
71 | * |
||
72 | * @param string $path The path to the file. |
||
73 | * @return array|false The file metadata or false on failure. |
||
74 | */ |
||
75 | 1 | public function getMetadata($path) |
|
79 | |||
80 | /** |
||
81 | * Get a file's size. |
||
82 | * |
||
83 | * @param string $path The path to the file. |
||
84 | * @return int|false The file size or false on failure. |
||
85 | */ |
||
86 | 1 | public function getSize($path) |
|
90 | |||
91 | /** |
||
92 | * Get a file's mime-type. |
||
93 | * |
||
94 | * @param string $path The path to the file. |
||
95 | * @return string|false The file mime-type or false on failure. |
||
96 | */ |
||
97 | 1 | public function getMimetype($path) |
|
101 | |||
102 | /** |
||
103 | * Get a file's timestamp. |
||
104 | * |
||
105 | * @param string $path The path to the file. |
||
106 | * @return string|false The timestamp or false on failure. |
||
107 | */ |
||
108 | 1 | public function getTimestamp($path) |
|
112 | |||
113 | /** |
||
114 | * Get a file's visibility. |
||
115 | * |
||
116 | * @param string $path The path to the file. |
||
117 | * @return string|false The visibility (public|private) or false on failure. |
||
118 | */ |
||
119 | 1 | public function getVisibility($path) |
|
123 | |||
124 | /** |
||
125 | * Write a new file. |
||
126 | * |
||
127 | * @param string $path The path of the new file. |
||
128 | * @param string $contents The file contents. |
||
129 | * @param array $config An optional configuration array. |
||
130 | * @return bool True on success, false on failure. |
||
131 | */ |
||
132 | 1 | public function write($path, $contents, array $config = []) |
|
136 | |||
137 | /** |
||
138 | * Write a new file using a stream. |
||
139 | * |
||
140 | * @param string $path The path of the new file. |
||
141 | * @param resource $resource The file handle. |
||
142 | * @param array $config An optional configuration array. |
||
143 | * @return bool True on success, false on failure. |
||
144 | */ |
||
145 | 1 | public function writeStream($path, $resource, array $config = []) |
|
149 | |||
150 | /** |
||
151 | * Update an existing file. |
||
152 | * |
||
153 | * @param string $path The path of the existing file. |
||
154 | * @param string $contents The file contents. |
||
155 | * @param array $config An optional configuration array. |
||
156 | * @return bool True on success, false on failure. |
||
157 | */ |
||
158 | 1 | public function update($path, $contents, array $config = []) |
|
162 | |||
163 | /** |
||
164 | * Update an existing file using a stream. |
||
165 | * |
||
166 | * @param string $path The path of the existing file. |
||
167 | * @param resource $resource The file handle. |
||
168 | * @param array $config An optional configuration array. |
||
169 | * @return bool True on success, false on failure. |
||
170 | */ |
||
171 | 1 | public function updateStream($path, $resource, array $config = []) |
|
175 | |||
176 | /** |
||
177 | * Rename a file. |
||
178 | * |
||
179 | * @param string $path Path to the existing file. |
||
180 | * @param string $newpath The new path of the file. |
||
181 | * @return bool True on success, false on failure. |
||
182 | */ |
||
183 | 1 | public function rename($path, $newpath) |
|
187 | |||
188 | /** |
||
189 | * Copy a file. |
||
190 | * |
||
191 | * @param string $path Path to the existing file. |
||
192 | * @param string $newpath The new path of the file. |
||
193 | * @return bool True on success, false on failure. |
||
194 | */ |
||
195 | 1 | public function copy($path, $newpath) |
|
199 | |||
200 | /** |
||
201 | * Delete a file. |
||
202 | * |
||
203 | * @param string $path |
||
204 | * @return bool True on success, false on failure. |
||
205 | */ |
||
206 | 1 | public function delete($path) |
|
210 | |||
211 | /** |
||
212 | * Delete a directory. |
||
213 | * |
||
214 | * @param string $dirname |
||
215 | * @return bool True on success, false on failure. |
||
216 | */ |
||
217 | 1 | public function deleteDir($dirname) |
|
221 | |||
222 | /** |
||
223 | * Create a directory. |
||
224 | * |
||
225 | * @param string $dirname The name of the new directory. |
||
226 | * @param array $config An optional configuration array. |
||
227 | * @return bool True on success, false on failure. |
||
228 | */ |
||
229 | 1 | public function createDir($dirname, array $config = []) |
|
233 | |||
234 | /** |
||
235 | * Set the visibility for a file. |
||
236 | * |
||
237 | * @param string $path The path to the file. |
||
238 | * @param string $visibility One of 'public' or 'private'. |
||
239 | * @return bool True on success, false on failure. |
||
240 | */ |
||
241 | 1 | public function setVisibility($path, $visibility) |
|
245 | |||
246 | /** |
||
247 | * Create a file or update if exists. |
||
248 | * |
||
249 | * @param string $path The path to the file. |
||
250 | * @param string $contents The file contents. |
||
251 | * @param array $config An optional configuration array. |
||
252 | * @return bool True on success, false on failure. |
||
253 | */ |
||
254 | 1 | public function put($path, $contents, array $config = []) |
|
258 | |||
259 | /** |
||
260 | * Create a file or update if exists. |
||
261 | * |
||
262 | * @param string $path The path to the file. |
||
263 | * @param resource $resource The file handle. |
||
264 | * @param array $config An optional configuration array. |
||
265 | * @return bool True on success, false on failure. |
||
266 | */ |
||
267 | 1 | public function putStream($path, $resource, array $config = []) |
|
271 | |||
272 | /** |
||
273 | * Read and delete a file. |
||
274 | * |
||
275 | * @param string $path The path to the file. |
||
276 | * @return string|false The file contents, or false on failure. |
||
277 | */ |
||
278 | 1 | public function readAndDelete($path) |
|
282 | } |
||
283 |