PHPDaemon\FS\FileWatcher::addWatch PHP Method

addWatch() public method

Adds your subscription on object in FS
public addWatch ( string $path, mixed $cb, integer $flags = null ) : true
$path string Path
$cb mixed Callback
$flags integer Look inotify_add_watch()
return true
    public function addWatch($path, $cb, $flags = null)
    {
        $path = realpath($path);
        if (!isset($this->files[$path])) {
            $this->files[$path] = [];
            if ($this->inotify) {
                $this->descriptors[inotify_add_watch($this->inotify, $path, $flags ?: IN_MODIFY)] = $path;
            }
        }
        $this->files[$path][] = $cb;
        Timer::setTimeout('fileWatcher');
        return true;
    }