1 | <?php |
||
15 | class NativeState { |
||
16 | /** |
||
17 | * @var resource |
||
18 | */ |
||
19 | protected $state; |
||
20 | |||
21 | protected $handlerSet = false; |
||
22 | |||
23 | protected $connected = false; |
||
24 | |||
25 | // todo replace with static once <5.6 support is dropped |
||
26 | // see error.h |
||
27 | private static $exceptionMap = [ |
||
28 | 1 => '\Icewind\SMB\Exception\ForbiddenException', |
||
29 | 2 => '\Icewind\SMB\Exception\NotFoundException', |
||
30 | 13 => '\Icewind\SMB\Exception\ForbiddenException', |
||
31 | 16 => '\Icewind\SMB\Exception\FileInUseException', |
||
32 | 17 => '\Icewind\SMB\Exception\AlreadyExistsException', |
||
33 | 20 => '\Icewind\SMB\Exception\InvalidTypeException', |
||
34 | 21 => '\Icewind\SMB\Exception\InvalidTypeException', |
||
35 | 22 => '\Icewind\SMB\Exception\InvalidArgumentException', |
||
36 | 28 => '\Icewind\SMB\Exception\OutOfSpaceException', |
||
37 | 39 => '\Icewind\SMB\Exception\NotEmptyException', |
||
38 | 110 => '\Icewind\SMB\Exception\TimedOutException', |
||
39 | 111 => '\Icewind\SMB\Exception\ConnectionRefusedException', |
||
40 | 112 => '\Icewind\SMB\Exception\HostDownException', |
||
41 | 113 => '\Icewind\SMB\Exception\NoRouteToHostException' |
||
42 | ]; |
||
43 | |||
44 | 510 | protected function handleError($path) { |
|
51 | |||
52 | 510 | protected function testResult($result, $uri) { |
|
64 | |||
65 | /** |
||
66 | * @param string $workGroup |
||
67 | * @param string $user |
||
68 | * @param string $password |
||
69 | * @return bool |
||
70 | */ |
||
71 | 510 | public function init($workGroup, $user, $password) { |
|
83 | |||
84 | /** |
||
85 | * @param string $uri |
||
86 | * @return resource |
||
87 | */ |
||
88 | 510 | public function opendir($uri) { |
|
94 | |||
95 | /** |
||
96 | * @param resource $dir |
||
97 | * @return array |
||
98 | */ |
||
99 | 510 | public function readdir($dir) { |
|
105 | |||
106 | /** |
||
107 | * @param $dir |
||
108 | * @return bool |
||
109 | */ |
||
110 | 510 | public function closedir($dir) { |
|
116 | |||
117 | /** |
||
118 | * @param string $old |
||
119 | * @param string $new |
||
120 | * @return bool |
||
121 | */ |
||
122 | 38 | public function rename($old, $new) { |
|
128 | |||
129 | /** |
||
130 | * @param string $uri |
||
131 | * @return bool |
||
132 | */ |
||
133 | 248 | public function unlink($uri) { |
|
139 | |||
140 | /** |
||
141 | * @param string $uri |
||
142 | * @param int $mask |
||
143 | * @return bool |
||
144 | */ |
||
145 | 510 | public function mkdir($uri, $mask = 0777) { |
|
151 | |||
152 | /** |
||
153 | * @param string $uri |
||
154 | * @return bool |
||
155 | */ |
||
156 | 510 | public function rmdir($uri) { |
|
162 | |||
163 | /** |
||
164 | * @param string $uri |
||
165 | * @return array |
||
166 | */ |
||
167 | 242 | public function stat($uri) { |
|
173 | |||
174 | /** |
||
175 | * @param resource $file |
||
176 | * @return array |
||
177 | */ |
||
178 | public function fstat($file) { |
||
184 | |||
185 | /** |
||
186 | * @param string $uri |
||
187 | * @param string $mode |
||
188 | * @param int $mask |
||
189 | * @return resource |
||
190 | */ |
||
191 | 108 | public function open($uri, $mode, $mask = 0666) { |
|
197 | |||
198 | /** |
||
199 | * @param string $uri |
||
200 | * @param int $mask |
||
201 | * @return resource |
||
202 | */ |
||
203 | 248 | public function create($uri, $mask = 0666) { |
|
209 | |||
210 | /** |
||
211 | * @param resource $file |
||
212 | * @param int $bytes |
||
213 | * @return string |
||
214 | */ |
||
215 | 102 | public function read($file, $bytes) { |
|
221 | |||
222 | /** |
||
223 | * @param resource $file |
||
224 | * @param string $data |
||
225 | * @param int $length |
||
226 | * @return int |
||
227 | */ |
||
228 | 244 | public function write($file, $data, $length = null) { |
|
234 | |||
235 | /** |
||
236 | * @param resource $file |
||
237 | * @param int $offset |
||
238 | * @param int $whence SEEK_SET | SEEK_CUR | SEEK_END |
||
239 | * @return int|bool new file offset as measured from the start of the file on success, false on failure. |
||
240 | */ |
||
241 | 2 | public function lseek($file, $offset, $whence = SEEK_SET) { |
|
247 | |||
248 | /** |
||
249 | * @param resource $file |
||
250 | * @param int $size |
||
251 | * @return bool |
||
252 | */ |
||
253 | 2 | public function ftruncate($file, $size) { |
|
259 | |||
260 | 244 | public function close($file) { |
|
266 | |||
267 | /** |
||
268 | * @param string $uri |
||
269 | * @param string $key |
||
270 | * @return string |
||
271 | */ |
||
272 | 28 | public function getxattr($uri, $key) { |
|
278 | |||
279 | /** |
||
280 | * @param string $uri |
||
281 | * @param string $key |
||
282 | * @param string $value |
||
283 | * @param int $flags |
||
284 | * @return mixed |
||
285 | */ |
||
286 | 16 | public function setxattr($uri, $key, $value, $flags = 0) { |
|
292 | |||
293 | 510 | public function __destruct() { |
|
298 | } |
||
299 |