1 | <?php |
||
28 | class NativeState { |
||
29 | /** |
||
30 | * @var resource |
||
31 | */ |
||
32 | protected $state; |
||
33 | |||
34 | protected $handlerSet = false; |
||
35 | |||
36 | protected $connected = false; |
||
37 | |||
38 | // see error.h |
||
39 | const EXCEPTION_MAP = [ |
||
40 | 1 => ForbiddenException::class, |
||
41 | 2 => NotFoundException::class, |
||
42 | 13 => ForbiddenException::class, |
||
43 | 16 => FileInUseException::class, |
||
44 | 17 => AlreadyExistsException::class, |
||
45 | 20 => InvalidTypeException::class, |
||
46 | 21 => InvalidTypeException::class, |
||
47 | 22 => InvalidArgumentException::class, |
||
48 | 28 => OutOfSpaceException::class, |
||
49 | 39 => NotEmptyException::class, |
||
50 | 110 => TimedOutException::class, |
||
51 | 111 => ConnectionRefusedException::class, |
||
52 | 112 => HostDownException::class, |
||
53 | 113 => NoRouteToHostException::class |
||
54 | ]; |
||
55 | |||
56 | 255 | protected function handleError($path) { |
|
63 | |||
64 | 255 | protected function testResult($result, $uri) { |
|
76 | |||
77 | /** |
||
78 | * @param IAuth $auth |
||
79 | * @return bool |
||
80 | */ |
||
81 | 255 | public function init(IAuth $auth) { |
|
94 | |||
95 | /** |
||
96 | * @param string $uri |
||
97 | * @return resource |
||
98 | */ |
||
99 | 255 | public function opendir($uri) { |
|
105 | |||
106 | /** |
||
107 | * @param resource $dir |
||
108 | * @return array |
||
109 | */ |
||
110 | 255 | public function readdir($dir) { |
|
116 | |||
117 | /** |
||
118 | * @param $dir |
||
119 | * @return bool |
||
120 | */ |
||
121 | 255 | public function closedir($dir) { |
|
127 | |||
128 | /** |
||
129 | * @param string $old |
||
130 | * @param string $new |
||
131 | * @return bool |
||
132 | */ |
||
133 | 19 | public function rename($old, $new) { |
|
139 | |||
140 | /** |
||
141 | * @param string $uri |
||
142 | * @return bool |
||
143 | */ |
||
144 | 124 | public function unlink($uri) { |
|
150 | |||
151 | /** |
||
152 | * @param string $uri |
||
153 | * @param int $mask |
||
154 | * @return bool |
||
155 | */ |
||
156 | 255 | public function mkdir($uri, $mask = 0777) { |
|
162 | |||
163 | /** |
||
164 | * @param string $uri |
||
165 | * @return bool |
||
166 | */ |
||
167 | 255 | public function rmdir($uri) { |
|
173 | |||
174 | /** |
||
175 | * @param string $uri |
||
176 | * @return array |
||
177 | */ |
||
178 | 121 | public function stat($uri) { |
|
184 | |||
185 | /** |
||
186 | * @param resource $file |
||
187 | * @return array |
||
188 | */ |
||
189 | public function fstat($file) { |
||
195 | |||
196 | /** |
||
197 | * @param string $uri |
||
198 | * @param string $mode |
||
199 | * @param int $mask |
||
200 | * @return resource |
||
201 | */ |
||
202 | 54 | public function open($uri, $mode, $mask = 0666) { |
|
208 | |||
209 | /** |
||
210 | * @param string $uri |
||
211 | * @param int $mask |
||
212 | * @return resource |
||
213 | */ |
||
214 | 124 | public function create($uri, $mask = 0666) { |
|
220 | |||
221 | /** |
||
222 | * @param resource $file |
||
223 | * @param int $bytes |
||
224 | * @return string |
||
225 | */ |
||
226 | 51 | public function read($file, $bytes) { |
|
232 | |||
233 | /** |
||
234 | * @param resource $file |
||
235 | * @param string $data |
||
236 | * @param int $length |
||
237 | * @return int |
||
238 | */ |
||
239 | 122 | public function write($file, $data, $length = null) { |
|
245 | |||
246 | /** |
||
247 | * @param resource $file |
||
248 | * @param int $offset |
||
249 | * @param int $whence SEEK_SET | SEEK_CUR | SEEK_END |
||
250 | * @return int|bool new file offset as measured from the start of the file on success, false on failure. |
||
251 | */ |
||
252 | 1 | public function lseek($file, $offset, $whence = SEEK_SET) { |
|
258 | |||
259 | /** |
||
260 | * @param resource $file |
||
261 | * @param int $size |
||
262 | * @return bool |
||
263 | */ |
||
264 | 1 | public function ftruncate($file, $size) { |
|
270 | |||
271 | 122 | public function close($file) { |
|
277 | |||
278 | /** |
||
279 | * @param string $uri |
||
280 | * @param string $key |
||
281 | * @return string |
||
282 | */ |
||
283 | 14 | public function getxattr($uri, $key) { |
|
289 | |||
290 | /** |
||
291 | * @param string $uri |
||
292 | * @param string $key |
||
293 | * @param string $value |
||
294 | * @param int $flags |
||
295 | * @return mixed |
||
296 | */ |
||
297 | 8 | public function setxattr($uri, $key, $value, $flags = 0) { |
|
303 | |||
304 | 255 | public function __destruct() { |
|
309 | } |
||
310 |