mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
add basic smb notify support
at the moment this only works when using the smbclient based backend
This commit is contained in:
parent
c50d9aa6a5
commit
cf23de2702
4 changed files with 56 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue