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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1:   //   // Basic filesystem monitor.   // - // $Id: basic.pike,v 1.17 2009/07/22 15:08:28 grubba Exp $ + // $Id: basic.pike,v 1.18 2009/07/22 15:37:40 grubba Exp $   //   // 2009-07-09 Henrik Grubbström   //      //! Basic filesystem monitor.   //!   //! This module is intended to be used for incremental scanning of   //! a filesystem.      //! The default maximum number of seconds between checks of directories
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:388:    last_change = 0x7fffffff;    if (stable_data_change) {    stable_data_change(path, st);    }    return 1;    }    return 0;    }   }    + //! Canonicalize a path. + //! + //! @param path + //! Path to canonicalize. + //! + //! @returns + //! The default implementation returns @expr{combine_path(path, ".")@}, + //! i.e. no trailing slashes. + protected string canonic_path(string path) + { +  return combine_path(path, "."); + } +    //! Mapping from monitored path to corresponding @[Monitor].   //! - //! The paths are normalized to @expr{combine_path(path, ".")@}, - //! i.e. no trailing slashes. + //! The paths are normalized to @expr{canonic_path(path)@},   //!   //! @note   //! All filesystems are handled as if case-sensitive. This should   //! not be a problem for case-insensitive filesystems as long as   //! case is maintained.   protected mapping(string:Monitor) monitors = ([]);      //! Heap containing all active @[Monitor]s.   //!   //! The heap is sorted on @[Monitor()->next_poll].
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:526:   //! Override of @[default_stable_time] for this path   //! or subtree.   //!   //! @seealso   //! @[release()]   void monitor(string path, MonitorFlags|void flags,    int(0..)|void max_dir_check_interval,    int(0..)|void file_interval_factor,    int(0..)|void stable_time)   { -  path = combine_path(path, "."); +  path = canonic_path(path);    Monitor m = monitors[path];    if (m) {    if (!(flags & MF_AUTO)) {    // The new monitor is added by hand.    // Adjust the monitor.    m->flags = flags;    m->max_dir_check_interval = max_dir_check_interval;    m->file_interval_factor = file_interval_factor;    m->stable_time = stable_time;    m->next_poll = 0;
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:569:   //! Release the entire subtree.   //! @value 3   //! Release the entire subtree, but only those paths that were   //! added automatically by a recursive monitor.   //! @endint   //!   //! @seealso   //! @[monitor()]   void release(string path, MonitorFlags|void flags)   { -  path = combine_path(path, "."); +  path = canonic_path(path);    Monitor m = m_delete(monitors, path);    if (m) {    release_monitor(m);    }    if (flags && m->st && m->st->isdir) { -  path = combine_path(path, ""); +  if (!sizeof(path) || path[-1] != '/') { +  path += "/"; +  }    foreach(monitors; string mpath; m) {    if (has_prefix(mpath, path) && ((m->flags & flags) == flags)) {    m_delete(monitors, mpath);    release_monitor(m);    }    }    }   }      //! Check a single @[Monitor] for changes.