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 | public function __construct($host, IAuth $auth, System $system, TimeZoneProvider $timeZoneProvider) { |
||
28 | parent::__construct($host, $auth, $system, $timeZoneProvider); |
||
29 | $this->state = new NativeState(); |
||
30 | } |
||
31 | |||
32 | protected function connect() { |
||
33 | $this->state->init($this->getAuth()); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return \Icewind\SMB\IShare[] |
||
38 | * @throws \Icewind\SMB\Exception\AuthenticationException |
||
39 | * @throws \Icewind\SMB\Exception\InvalidHostException |
||
40 | */ |
||
41 | public function listShares() { |
||
42 | $this->connect(); |
||
43 | $shares = array(); |
||
44 | $dh = $this->state->opendir('smb://' . $this->getHost()); |
||
45 | while ($share = $this->state->readdir($dh)) { |
||
46 | if ($share['type'] === 'file share') { |
||
47 | $shares[] = $this->getShare($share['name']); |
||
48 | } |
||
49 | } |
||
50 | $this->state->closedir($dh); |
||
51 | return $shares; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param string $name |
||
56 | * @return \Icewind\SMB\IShare |
||
57 | */ |
||
58 | public function getShare($name) { |
||
59 | 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 |