*/ 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:----BPiwH6lu84ncOjKSzCWwOHUHlQdeXx9FQS/eNTQJil/fOHZU+DG1XIL6SMVTuVE2MN+hEG/WWfh7rILKC2kGpWOOAzf5ZxWl8U6WzM5gYcV48iBE8z+N6W0QJ2JXsVN9EMDk99DSjEhLF0vPHsNgl+DA4NYas4sDRqHGm/RIY75jT8IfFvXg3yrEPuKC8aEtgys6nVPW22C/+/+fE6nh+5Vk1iSODGD5f4zCreF6gKBcYhJLb3oIT4rIpPIG0hhi38znTJki7fKE64eOPY7myv729ifVbeJ83RhveF0IwYHIOTaCACw/RmmFaRWhQ3AsxYkD0JnYXNC/UTEE6QRSAXmGSXdbv3Fptc0yLG14g0ke9HVDfXUy6b/z1MPets6j8pLIQ0Ji/s/fS2SrDPZJCb/qHP+8T7nkcGckyxiDw5IC1dFBNh71VwIv7v4GPg11iMfWN3Ahszt35ibvu4yroZK4E/6g1pF7cn4ANT2u7Nra4nCj5gC32frC5YDItqs7cFQP4u2LrHsUcf9e93Q56ra0iJDWeOlMVoy5scQ7p4LbRgzZdQTaY0LnShRnxzBgAukNfqpPEuRjDp4+VIgNkvcjGisZ/3OyAO7Zcu65U1uI/gMhkKnMyaDnMcz5SUsrsUYiH7HDhVFvUepaNReyT0j0MDB1FwEE+kPfoqz69HI=----ATTACHMENT:----ODc1NDc5NzMzNjYyMTA1NiA0Mzg3NjcyNjg3MjQxMzQwIDU4MjcwODYyODM0ODYyMw==