This class provides access to various base functions of system platforms. Look in the sys package for more system APIs.

Static methods

@:has_untypedstaticargs():Array<String>

Returns all the arguments that were passed in the command line. This does not include the interpreter or the name of the program file.

(java)(eval) On Windows, non-ASCII Unicode arguments will not work correctly.

(cs) Non-ASCII Unicode arguments will not work correctly.

@:has_untypedstaticcommand(cmd:String, ?args:Array<String>):Int

Runs the given command. The command output will be printed to the same output as the current process. The current process will block until the command terminates. The return value is the exit code of the command (usually 0 indicates no error).

Command arguments can be passed in two ways:

  1. Using args to pass command arguments. Each argument will be automatically quoted and shell meta-characters will be escaped if needed. cmd should be an executable name that can be located in the PATH environment variable, or a full path to an executable.

  2. When args is not given or is null, command arguments can be appended to cmd. No automatic quoting/escaping will be performed. cmd should be formatted exactly as it would be when typed at the command line. It can run executables, as well as shell commands that are not executables (e.g. on Windows: dir, cd, echo etc).

Use the sys.io.Process API for more complex tasks, such as background processes, or providing input to the command.

staticexit(code:Int):Void

Exits the current process with the given exit code.

(macro)(eval) Being invoked in a macro or eval context (e.g. with -x or --run) immediately terminates the compilation process, which also prevents the execution of any --next sections of compilation arguments.

staticgetCwd():String

Gets the current working directory (usually the one in which the program was started).

@:has_untypedstaticgetEnv(s:String):String

Returns the value of the given environment variable, or null if it doesn't exist.

@:has_untypedstaticprint(v:Dynamic):Void

Prints any value to the standard output.

@:has_untypedstaticprintln(v:Dynamic):Void

Prints any value to the standard output, followed by a newline. On Windows, this function outputs a CRLF newline. LF newlines are printed on all other platforms.

@:has_untypedstaticsetCwd(s:String):Void

Changes the current working directory.

(java) This functionality is not available on Java; calling this function will throw.

staticsleep(seconds:Float):Void

Suspends execution for the given length of time (in seconds).

staticsystemName():String

Returns the type of the current system. Possible values are: - "Windows" - "Linux" - "BSD" - "Mac"

statictime():Float

Gives the most precise timestamp value available (in seconds).