Fan

 

final class

sys::Sys

sys::Obj
  sys::Sys

Sys provides static access to the system's environment.

Slots

appDirSource

static File appDir()

Get the application home directory. The appDir is automatically exposed into the namespace as part of the root Resource:

  • In fand this is the app directory used to boot the namespace (TODO - revisit this)
  • In fant this is the test directory.
  • In other VMs it is the current working directory.
argsSource

static Str[] args()

Get the command line arguments used to run the fan process as a readonly List of strings.

compileSource

static Type compile(File f, [Str:Obj]? options := null)

Compile a script file into a pod and return the first public type declared in the script file. If the file has been previously compiled and hasn't changed, then a cached type is returned. If the script contains errors then the first CompilerErr found is thrown. The options available:

  • logLevel: the default LogLevel to use for logging the compilation process and errors
  • log: the compiler::CompilerLog to use for logging the compilation process and errors
  • force: pass true to not use caching, always forces a recompile
diagnosticsSource

static Str:Obj diagnostics()

Poll for a platform dependent map of diagnostics name/value pairs for the current state of the VM. Java platforms return key values from the java.lang.management interface.

envSource

static Str:Str env()

Get the environment variables as a case insensitive, readonly map of Str name/value pairs. The environment map is initialized from the following sources from lowest priority to highest priority:

  1. shell environment variables
  2. Java system properties (Java VM only obviously)
  3. {homeDir}/lib/sys.props

The following environment variables are always available:

  • os.name: name of the host operating system
  • os.version: version of the host operating system
errSource

static OutStream err()

Standard error output stream.

exitSource

static Void exit(Int status := 0)

Terminate the current virtual machine.

gcSource

static Void gc()

Run the garbage collector. No guarantee is made to what the VM will actually do.

homeDirSource

static File homeDir()

Get the fan installation home directory.

hostNameSource

static Str hostName()

Get the local host name of the machine running the virtual machine process.

idHashSource

static Int idHash(Obj? obj)

Return the default hash code of Obj.hash for the specified object regardless of whether the object has overridden the hash method. If null then return 0.

inSource

static InStream in()

Standard output stream.

mountSource

static Void mount(Uri uri, Namespace ns)

Mount a namespace under the specified Uri. All requests to process uris contained by the specified uri are routed to the namespace instance for processing. Throw ArgErr if the uri is already or mounted by another namespace. Throw ArgErr if the uri isn't path absolute, has a query, or has fragment.

nsSource

static Namespace ns(Uri? uri := null)

Get the namespace instance which manages the specified uri, or if uri is omitted, then get the root namespace.

outSource

static OutStream out()

Standard output stream.

unmountSource

static Void unmount(Uri uri)

Unmount a namespace which was previously mounted by the mount method. Throw UnresolvedErr is uri doesn't directly map to a mounted namespace.

userNameSource

static Str userName()

Get the user name of the user account used to run the virtual machine process.