Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • 9.0
  • 8.0
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • nt-tools
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
  • v8.0.1982
  • v8.0.1980
  • v8.0.1978
  • v8.0.1976
  • v8.0.1974
  • v8.0.1972
  • v8.0.1970
  • v8.0.1968
  • v8.0.1966
  • v8.0.1964
  • v8.0.1962
40 results

Local.pmod

Blame
  • Local.pmod 2.00 KiB
    #pike __REAL_VERSION__
    
    //! @[Local] gives a local module namespace used for locally
    //! installed pike modules.
    //!
    //! Modules are searched for in the directory @tt{pike_modules@} which
    //! can be located in the user's home directory or profile directory,
    //! or in any of the system directories @tt{/opt/share,
    //! /usr/local/share, /opt@} or @tt{/usr/local/@}.
    //!
    //! The user's home directory is determined by examining the
    //! environment variable HOME, and if that fails the environment
    //! variable USERPROFILE.
    //!
    //! If the environment variable PIKE_LOCAL_PATH is set, the paths
    //! specified there will be searched first.
    //!
    //! @example
    //!  If the user has installed the pike module @tt{Mine.pmod@} in the
    //!  directory @tt{$HOME/pike_modules@}.  it can be accessed as
    //!  @tt{Local.Mine@}.
    //!
    //! @seealso
    //!   @[Local.add_path()], @[Local.remove_path()]
    
    inherit __joinnode;
    
    protected array(string) local_path;
    
    protected void create()
    {
      ::create(({}));
    
      // FIXME $prefix/pike_modules
      // FIXME All this should be controllable from .pikerc, when such a file is implemented...
    
      add_path("/usr/local/pike_modules");
      add_path("/opt/pike_modules");
      add_path("/opt/share/pike_modules");
      add_path("/usr/local/share/pike_modules");
    
      string tmp;
      if( (tmp=[string]getenv("HOME")) || (tmp=[string]getenv("USERPROFILE")) ) {
        tmp = (tmp[-1]=='/'?tmp:tmp+"/")+"pike_modules/";
        add_path(tmp);
      }
    
      if(tmp = [string]getenv("PIKE_LOCAL_PATH") ) {
        array to_add=reverse(tmp/":"); // preserve order
        add_path( to_add[*] ); 
      }
    }
    
    //! @decl int(0..1) add_path(string path)
    //!
    //! This function prepends @[path] to the @[Local] module
    //! searchpath.
    //!
    //! @param path
    //!   The path to the directory to be added.
    //!
    //! @returns
    //!   Returns 1 on success, otherwise 0.
    
    //! This function removes @[path] from the @[Local] module
    //! searchpath. If @[path] is not in the search path, this is
    //! a noop.
    //!
    //! @param path
    //!   The path to be removed.
    //!
    void remove_path(string path)
    {
      rem_path(path);
    }