Skip to content
Snippets Groups Projects
Select Git revision
  • e8084d4d3becd9bdb34908438176855b5961d583
  • 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.2000
  • v8.0.1998
  • 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
41 results

Array.pmod

Blame
  • module.pmod 1.49 KiB
    #pike __REAL_VERSION__
    #pragma strict_types
    
    // This module is to allow the _system module to be called System.
    
    inherit _system;
    
    constant Timer = __builtin.Timer;
    constant Time  = __builtin.Time;
    #if constant(__builtin.TM)
    constant TM    = __builtin.TM;
    #endif
    //! Get the username of the user that started the process.
    //!
    //! @returns
    //!  the username of the user "associated" with the current process, or zero
    //!  if a method to find this information does not exist on the current system.
    //!
    //! @note
    //!  On NT systems, this returns the user the current thread is running as,
    //!  while on Unix-like systems this function returns the user that started
    //!  the process (rather than the effective user)..
    string get_user()
    {
    #if constant(_system.GetUserName)
      return GetUserName();
    #elseif constant(getuid)
      return [string]getpwuid(getuid())[0];
    #else
      return 0;
    #endif
    }
    
    //! Get the full path for the current user's home directory
    //!
    //! @returns
    //! the full path to the current user's home directory, or zero
    //! if the appropriate environment variables have not been set.
    //!
    //! @note
    //! This method uses the standard environment variables for
    //! various systems to determine the home directory.
    string get_home()
    {
      string home = [string]getenv("HOME");
      if(home) return home;
    
    #if __NT__
      string homedrive = [string]getenv("HOMEDRIVE");
      home = [string]getenv("HOMEPATH");
      if(homedrive)
        home = combine_path(homedrive + "\\", (home||"\\"));
      if(home) return home;
    #endif
    
      return 0;      
    }