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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:743:   #endif      #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]; -  if(monitors[path]) -  { +  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();    } -  else check_all(); +    }      //! 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); +  if ((last_change != 0x7fffffff) && accellerated) { +  // Not stable yet. +  int t = time(1) - last_change; +  if (t < 0) t = 0; +  (backend || Pike.DefaultBackend)-> +  call_out(check, (stable_time || global::stable_time) + 1 - t); +  } +  } +  +  protected void file_created(string path, Stdio.Stat st) +  { +  if (accellerated) { +  (backend || Pike.DefaultBackend)-> +  call_out(check, (stable_time || global::stable_time) + 1); +  } +  ::file_created(path, st); +  } +  +  protected void attr_changed(string path, Stdio.Stat st) +  { +  if (accellerated) { +  (backend || Pike.DefaultBackend)-> +  call_out(check, (stable_time || global::stable_time) + 1); +  } +  ::attr_changed(path, st); +  } +     protected void register_path(int|void initial)    {    if (backend) {    // CFRunLoop only works with the primary backend.    ::register_path(initial);    return;    }    if (!initial) return;       if (!eventstream) {
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:813: Inside #if HAVE_EVENTSTREAM
   eventstream->stop();    eventstream->add_path(path);    eventstream->start();    // 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 (ret) return ret;       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;