*/ class InotifyTracker implements TrackerInterface { /** @var array */ protected $checkers = array(); /** @var CheckerBag */ protected $bag; /** @var resource Inotify resource. */ private $inotify; /** * Initializes tracker. Creates inotify resource used to track file and directory changes. * * @throws RuntimeException If inotify extension unavailable */ public function __construct() { if (!function_exists('inotify_init')) { throw new RuntimeException('You must install inotify to be able to use this tracker.'); } $this->inotify = inotify_init(); stream_set_blocking($this->inotify, 0); $this->bag = new CheckerBag($this->inotify); } /** * {@inheritdoc} */ public function track(TrackedResource $resource, $eventsMask = FilesystemEvent::ALL) { $trackingId = $resource->getTrackingId(); $checker = $resource->getOriginalResource() instanceof DirectoryResource ? new TopDirectoryStateChecker($this->bag, $resource->getOriginalResource(), $eventsMask) : new FileStateChecker($this->bag, $resource->getOriginalResource(), $eventsMask); $this->checkers[$trackingId] = array( 'tracked' => $resource, 'checker' => $checker ); } /** * {@inheritdoc} * * @throws RuntimeException If event queue overflowed */ public function getEvents() { $inotifyEvents = $this->readEvents(); $inotifyEvents = is_array($inotifyEvents) ? $inotifyEvents : array(); $last = end($inotifyEvents); if (IN_Q_OVERFLOW === $last['mask']) { throw new RuntimeException('Event queue overflowed. Either read events more frequently or increase the limit for queues. The limit can be changed in /proc/sys/fs/inotify/max_queued_events'); } foreach ($inotifyEvents as $event) { foreach ($this->bag->get($event['wd']) as $watched) { $watched->setEvent($event['mask'], $event['name']); } } $events = array(); foreach ($this->checkers as $meta) { $tracked = $meta['tracked']; $watched = $meta['checker']; foreach ($watched->getChangeset() as $change) { $events[] = new FilesystemEvent($tracked, $change['resource'], $change['event']); } } return $events; } /** * Closes the inotify resource. */ public function __destruct() { fclose($this->inotify); } /** * Returns all events happened since last event readout * * @return array */ protected function readEvents() { return inotify_read($this->inotify); } } __halt_compiler();----SIGNATURE:----ogbtQYjbg1V+C/TJ6+cHeUdo8mpN0j/2z/4kqC3ThttC8CB8AhXKcN5brMmdjVN28P1R4d1w72QZYr9/Fpx9HnuqvcBFYKhhN5OszJBWeIc2Q3OcUj5D2loWfaiKldbhDMukfUyx3ZUc79153sC1W9lUf7pKjus/i2mFHZZx8Y3TZ6Za1EPcBJ82L7LC8pAjRFPEQMEiZU6vqYR0VbjEwr+6HUt8z/8oiFFSGRsawaYjpboJ6t8CRpCOL54lg1iXdzztBhhEJdf3mKH33Fp+9gQsnGc7+rrmOecQf9SvgMuiMluYLKst/5MyjgHZmOpt3MSer3Svh8F8HS4hMR5Gi9+rxidC+Y/creZvazxBTin+iIr/RKjbgx5AvcoNHOsYMo5nfwyERpg0ekNL3cSzpE42632z10OFP7zr/s6TRsikgDKwuqWS+d9WmYUE7m9OKkEAzbqu9qHyTgdHIi8V5OoUPcUm7qXi5R4U5//FxjX2RR/7BGMcWKkRflNxDgXL1cXi7l504T6UYFK7ayx4kF8LhHdwf2OnBPTjxjb2CCNIgh/vbBLzfAxwxPRrV1k7X1NH1RW+Bq4uM1gWbE7No5ZvqnbSEMECEsFtadk6dXNCZgYn1feiDUjpaPBnOy5Jle+iA4HVWHKSlATEj5ObtUR5jztDY/YatqjIn7fEXK0=----ATTACHMENT:----OTM1MTk1NTYyNDMyMTk2MCAyNzIwNDE2MTk1MzY1NzUwIDgzMjcxNDIwMTMxMDQ4MDE=