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