Branch: Tag:

2012-07-16

2012-07-16 03:58:46 by Bill Welliver <bill@welliver.org>

System: added AllocConsole, FreeConsole and AttachConsole for Windows. Also added cross-platform stubs for get_home() and get_user()

7:      constant Timer = __builtin.Timer;   constant Time = __builtin.Time; +  + //! Get the username of the user the process is running as. + //! + //! @note + //! On NT systems, this returns the user the current thread is running as. + string get_user() + { + #if constant(System.GetUserName) +  return System.GetUserName(); + #elseif constant(System.getuid) +  return getpwuid(System.getuid())[0]; + #else +  return "UNKNOWN"; + #endif /* System.GetUserName */ + } +  + //! Get the full path for the current user's home directory + string get_home() + { +  string home = getenv("HOME"); +  if(home) return home; +  + #if __NT__ +  string homedrive = getenv("HOMEDRIVE"); +  home = getenv("HOMEPATH"); +  if(homedrive) +  home = homedrive + home; +  if(home) return home; + #endif +  +  throw("Unable to determine HOME directory.\n"); + } +