pike.git / lib / modules / Filesystem.pmod / Monitor.pmod / basic.pike

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:746: Inside #if HAVE_EVENTSTREAM
  protected System.FSEvents.EventStream eventstream;   protected array(string) eventstream_paths = ({});      //! This function is called when the FSEvents EventStream detects a change   //! in one of the monitored directories.   protected void eventstream_callback(string path, int flags, int event_id)   {    MON_WERR("eventstream_callback(%O, 0x%08x, %O)\n", path, flags, event_id);    if(path[-1] == '/') path = path[0..<1];    MON_WERR("Normalized path: %O\n", path); -  if(monitors[path]) { -  monitors[path]->check(0); -  } else { -  MON_WERR("No monitor found for path %O. Checking all monitors...\n", path); -  check_all(); +  +  int monitor_flags; +  +  if (flags & System.FSEvents.kFSEventStreamEventFlagMustScanSubDirs) +  monitor_flags &= MF_RECURSE; +  +  int found; +  string checkpath = path; +  for (int i = 0; i <= 1; i++) { +  MON_WERR("Looking up monitor for path %O.\n", checkpath); +  if(Monitor m = monitors[checkpath]) { +  MON_WERR("Found monitor %O for path %O.\n", m, checkpath); +  m->check(monitor_flags); +  found = 1; +  break;    } -  +  checkpath = dirname (checkpath);    }    -  +  if (!found) +  MON_WERR("No monitor found for path %O.\n", path); + } +    //! FSEvents EventStream-accellerated @[Monitor].   protected class EventStreamMonitor   {    inherit Monitor;       int(0..1) accellerated;       protected void file_exists(string path, Stdio.Stat st)    {    ::file_exists(path, st);
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:806: Inside #if HAVE_EVENTSTREAM
   return;    }   #ifndef INHIBIT_EVENTSTREAM_MONITOR    if (!initial) return;       if (!eventstream) {    // Make sure that the main backend is in CF-mode.    Pike.DefaultBackend.enable_core_foundation(1);       MON_WERR("Creating event stream.\n"); + #if constant (System.FSEvents.kFSEventStreamCreateFlagFileEvents) +  int flags = System.FSEvents.kFSEventStreamCreateFlagFileEvents; + #else +  int flags = System.FSEvents.kFSEventStreamCreateFlagNone; + #endif +     eventstream =    System.FSEvents.EventStream(({}), 1.0,    System.FSEvents.kFSEventStreamEventIdSinceNow, -  System.FSEvents.kFSEventStreamCreateFlagNone); +  flags);    eventstream->callback_func = eventstream_callback;    } else {    string found;    foreach(eventstream_paths;;string p) {    if (path == p) {    // Unlikely, but...    // NB: Eventstream doesn't notify on the monitored path;    // only on its contents.    MON_WERR("Path %O already monitored.\n", path);    ::register_path(initial);
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:845: Inside #if HAVE_EVENTSTREAM and #if undefined(INHIBIT_EVENTSTREAM_MONITOR)
   eventstream_paths += ({path});    if(eventstream->is_started())    eventstream->stop();    eventstream->add_path(path);    eventstream->start();   #endif /* !INHIBIT_EVENTSTREAM_MONITOR */    // NB: Eventstream doesn't notify on the monitored path;    // only on its contents.    ::register_path(initial);    } -  -  int(0..1) check(MonitorFlags|void flags) -  { -  MON_WERR("Checking path %O...\n", path); -  int orig_flags = this::flags; -  -  int(0..1) ret = ::check(flags); -  if(orig_flags & MF_RECURSE) { -  // If using FSEvents, we won't receive the name of the file changed, -  // so we have to scan for it. -  array(string) files = get_dir(path) || ({}); -  this::files = files; -  foreach(files, string file) { -  file = canonic_path(Stdio.append_path(path, file)); -  if (monitors[file]) { -  if(check_monitor(monitors[file])) ret = 1; +    } -  } -  } -  return ret; -  } - } +       constant DefaultMonitor = EventStreamMonitor;      #elseif HAVE_INOTIFY      protected System.Inotify._Instance instance;      protected string(8bit) inotify_cookie(int wd)   {    // NB: Prefix with a NUL to make sure not to conflict with real paths.