1 | <?php |
||
21 | class DiskDriver implements FSDriverInterface{ |
||
22 | |||
23 | /** |
||
24 | * Checks if the given file exists. |
||
25 | * |
||
26 | * @param string $path the file path |
||
27 | * |
||
28 | * @return bool |
||
29 | */ |
||
30 | public function fileExists(string $path):bool{ |
||
33 | |||
34 | /** |
||
35 | * Checks if the given $path is a file. |
||
36 | * |
||
37 | * @param string $path the file path |
||
38 | * |
||
39 | * @return bool |
||
40 | */ |
||
41 | public function isFile(string $path):bool{ |
||
44 | |||
45 | /** |
||
46 | * Checks if the given $path is a directory. |
||
47 | * |
||
48 | * @param string $path the directory path |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function isDir(string $path):bool{ |
||
55 | |||
56 | /** |
||
57 | * Returns the given file's contents |
||
58 | * |
||
59 | * @param string $path the file path |
||
60 | * |
||
61 | * @return string the file's contents |
||
62 | * @throws \chillerlan\Filereader\FilereaderException |
||
63 | */ |
||
64 | public function fileContents(string $path):string{ |
||
72 | |||
73 | /** |
||
74 | * Requires the given source file and returns it's executed contents. |
||
75 | * Caution! This is a potential security leak. You could even eval(). |
||
76 | * |
||
77 | * @param string $path the file path |
||
78 | * |
||
79 | * @return mixed the file's executed contents |
||
80 | * @throws \chillerlan\Filereader\FilereaderException |
||
81 | */ |
||
82 | public function getRequire(string $path){ |
||
90 | |||
91 | /** |
||
92 | * Creates a new directory under $path. |
||
93 | * |
||
94 | * @param string $path |
||
95 | * |
||
96 | * @return bool |
||
97 | * @throws \chillerlan\Filereader\FilereaderException |
||
98 | */ |
||
99 | public function makeDir(string $path):bool{ |
||
107 | |||
108 | /** |
||
109 | * Deletes directory $path (if empty) |
||
110 | * |
||
111 | * @param string $path |
||
112 | * |
||
113 | * @return bool |
||
114 | * @throws \chillerlan\Filereader\FilereaderException |
||
115 | */ |
||
116 | public function deleteDir(string $path):bool{ |
||
124 | |||
125 | /** |
||
126 | * Deletes a file |
||
127 | * |
||
128 | * @param string $path |
||
129 | * |
||
130 | * @return bool |
||
131 | * @throws \chillerlan\Filereader\FilereaderException |
||
132 | */ |
||
133 | public function deleteFile(string $path):bool{ |
||
141 | |||
142 | /** |
||
143 | * Renames a file or directory from $oldname to $newname |
||
144 | * |
||
145 | * @param string $oldname |
||
146 | * @param string $newname |
||
147 | * @param bool $overwrite |
||
148 | * |
||
149 | * @return bool |
||
150 | * @throws \chillerlan\Filereader\FilereaderException |
||
151 | */ |
||
152 | public function rename(string $oldname, string $newname, bool $overwrite = true):bool{ |
||
160 | |||
161 | /** |
||
162 | * Copies a file from $source to $dest |
||
163 | * |
||
164 | * @param string $source |
||
165 | * @param string $destination |
||
166 | * @param bool $overwrite |
||
167 | * |
||
168 | * @return bool |
||
169 | * @throws \chillerlan\Filereader\FilereaderException |
||
170 | */ |
||
171 | public function copyFile(string $source, string $destination, bool $overwrite = true):bool{ |
||
179 | |||
180 | /** |
||
181 | * @param string $path |
||
182 | * @param string $data |
||
183 | * @param bool $overwrite |
||
184 | * |
||
185 | * @return int|bool |
||
186 | * @throws \chillerlan\Filereader\FilereaderException |
||
187 | */ |
||
188 | public function write(string $path, string $data, bool $overwrite = true){ |
||
196 | |||
197 | /** |
||
198 | * @param string $path |
||
199 | * |
||
200 | * @return int|null |
||
201 | */ |
||
202 | public function fileModifyTime(string $path):?int{ |
||
205 | |||
206 | /** |
||
207 | * @param string $path |
||
208 | * |
||
209 | * @return bool |
||
210 | * @throws \chillerlan\Filereader\FilereaderException |
||
211 | */ |
||
212 | public function isWritable(string $path):bool{ |
||
220 | |||
221 | /** |
||
222 | * @param string $pattern |
||
223 | * |
||
224 | * @return array |
||
225 | */ |
||
226 | public function findFiles(string $pattern):array { |
||
229 | |||
230 | } |
||
231 |