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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/symlinks.pike:14:   //! @note   //! For operating systems where symbolic links aren't supported,   //! this module will behave exactly like @[Filesystem.Monitor.basic].   //!   //! @seealso   //! @[Filesystem.Monitor.basic]      //! @decl inherit Filesystem.Monitor.basic   inherit "basic.pike" : basic;    + #define MON_WERR(X...) report(NOTICE, __func__, X) + #define MON_WARN(X...) report(WARNING, __func__, X) + #define MON_ERROR(X...) report(ERROR, __func__, X) +    #if constant(readlink)      //! @decl void attr_changed(string path, Stdio.Stat st)   //!   //! File attribute changed callback.   //!   //! @param path   //! Path of the file or directory which has changed attributes.   //!   //! @param st
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/symlinks.pike:121: Inside #if constant(readlink)
  //! Called by @[check()] and @[check_monitor()].   //!   //! Overload this to do something useful.      //! Monitoring information for a single filesystem path.   //!   //! With support for expansion of symbolic links.   //!   //! @seealso   //! @[monitor()] - protected class Monitor + protected class DefaultMonitor   { -  //! Based on @[Filesystem.Monitor.basic.Monitor]. -  inherit basic::Monitor; +  //! Based on @[Filesystem.Monitor.basic.DefaultMonitor]. +  inherit basic::DefaultMonitor;       //! Mask of symlink ids that can reach this monitor.    int symlinks;       //! Call a notification callback and handle symlink expansion.    //!    //! @param cb    //! Callback to call or @[UNDEFINED] for no operation.    //!    //! @param state
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/symlinks.pike:158: Inside #if constant(readlink)
   //! Symbolic link that must have been followed for the    //! callback to be called.    void low_call_callback(function(string, mixed ...:void) cb,    mapping(string:int) state,    mapping(string:string) symlink_targets,    string path, Stdio.Stat|void st,    string|void symlink)    {    if (!cb || state[path] || (st && st->islnk)) return;    state[path] = 1; +  +  MON_WERR("%O: path: %O, cb: %O, symlink_targets: %O\n", +  this_function, path, cb, symlink_targets); +     if (!symlink || !symlink_targets[symlink]) {    cb(path, st);    }    if (sizeof(symlink_targets)) {    // Check the list of symlink targets.    foreach(reverse(sort(indices(symlink_targets))), string src) {    string dest = symlink_targets[src];    if (has_prefix(path, dest)) {    low_call_callback(cb, state, symlink_targets - ([ src : dest ]),    src + path[sizeof(dest)..], st, symlink);
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/symlinks.pike:208: Inside #if constant(readlink)
   Monitor m = monitors[m_path];    m->low_call_callback(cb, ([]), global::symlink_targets,    m_path, m->st, sym);    }    }    }       //! Called when the symlink @[path] is no more.    protected void zap_symlink(string path)    { +  MON_WERR("%O(%O)\n", this_function, path); +     string old_dest = global::symlink_targets[path];       if (old_dest) {    int sym_id = global::symlink_ids[path];    foreach(monitors; string m_path; Monitor m) {    if (m->symlinks & sym_id) { -  +  MON_WERR("Found monitor %O reached through %O.\n", m, path);    m->low_call_callback(global::file_deleted, ([]),    global::symlink_targets,    m_path, UNDEFINED, path);    m->symlinks -= sym_id;    // Unregister the monitor if it is the last ref,    // and there are no hard links to the file.    m->check_for_release(MF_AUTO|MF_HARD, MF_AUTO);    }    }    global::available_ids |= m_delete(symlink_ids, path);    m_delete(global::symlink_targets, path);    }    }       //! Check whether a symlink has changed.    protected void check_symlink(string path, Stdio.Stat st,    int|void inhibit_notify)    { -  +  MON_WERR("%O(%O, %O, %O)...\n", this_function, path, st, inhibit_notify); +     string dest;    if (st && st->islnk) {    dest = readlink(path);    if (dest) {    dest = canonic_path(combine_path(path, "..", dest));    if (symlink_targets[path] == dest) return;    }    }    if (symlink_targets[path]) {    zap_symlink(path);    }    if (dest) {    // We have a new symbolic link. -  +  MON_WERR("Found new symlink %O ==> %O.\n", path, dest);    symlink_targets[path] = dest;    int sym_id = allocate_symlink(path);    int sym_mask = sym_id | symlink_ids[dest];    int sym_done = sym_id;    Monitor m;    if (!(m = monitors[dest])) {    MonitorFlags m_flags = (flags & ~MF_HARD) | MF_AUTO;    if (inhibit_notify) {    m_flags &= ~MF_INITED;    }