1 | <?php |
||
15 | class NativeServer extends AbstractServer { |
||
16 | /** |
||
17 | * @var NativeState |
||
18 | */ |
||
19 | protected $state; |
||
20 | |||
21 | /** |
||
22 | * @param string $host |
||
23 | * @param IAuth $auth |
||
24 | * @param System $system |
||
25 | * @param TimeZoneProvider $timeZoneProvider |
||
26 | */ |
||
27 | 255 | public function __construct($host, IAuth $auth, System $system, TimeZoneProvider $timeZoneProvider) { |
|
28 | 255 | parent::__construct($host, $auth, $system, $timeZoneProvider); |
|
29 | 255 | $this->state = new NativeState(); |
|
30 | 255 | } |
|
31 | |||
32 | 1 | protected function connect() { |
|
33 | 1 | $this->state->init($this->getAuth()); |
|
34 | 1 | } |
|
35 | |||
36 | /** |
||
37 | * @return \Icewind\SMB\IShare[] |
||
38 | * @throws \Icewind\SMB\Exception\AuthenticationException |
||
39 | * @throws \Icewind\SMB\Exception\InvalidHostException |
||
40 | */ |
||
41 | 1 | public function listShares() { |
|
42 | 1 | $this->connect(); |
|
43 | 1 | $shares = array(); |
|
44 | 1 | $dh = $this->state->opendir('smb://' . $this->getHost()); |
|
45 | 1 | while ($share = $this->state->readdir($dh)) { |
|
46 | 1 | if ($share['type'] === 'file share') { |
|
47 | 1 | $shares[] = $this->getShare($share['name']); |
|
48 | } |
||
49 | } |
||
50 | 1 | $this->state->closedir($dh); |
|
51 | 1 | return $shares; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param string $name |
||
56 | * @return \Icewind\SMB\IShare |
||
57 | */ |
||
58 | 255 | public function getShare($name) { |
|
59 | 255 | return new NativeShare($this, $name); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * Check if the smbclient php extension is available |
||
64 | * |
||
65 | * @param System $system |
||
66 | * @return bool |
||
67 | */ |
||
68 | public static function available(System $system) { |
||
71 | } |
||
72 |