add basic smb notify support

at the moment this only works when using the smbclient based backend
This commit is contained in:
Robin Appelman 2016-04-25 18:15:34 +02:00
commit cf23de2702
4 changed files with 56 additions and 2 deletions

View file

@ -344,6 +344,26 @@ class Share extends AbstractShare {
return $this->parseOutput($output, $path);
}
/**
* @param string $path
* @param callable $callback callable which will be called for each received change
* @return mixed
*/
public function notify($path, callable $callback) {
$this->connect();
$command = 'notify ' . $this->escapePath($path);
$this->connection->write($command . PHP_EOL);
$this->connection->read(function ($line) use ($callback, $path) {
$code = (int)substr($line, 0, 4);
$subPath = substr($line, 5);
if ($path === '') {
$callback($code, $subPath);
} else {
$callback($code, $path . '/' . $subPath);
}
});
}
/**
* @param string $command
* @return array