| 1 |
/* |
| 2 |
https://raw.githubusercontent.com/HaxeFoundation/haxe/development/std/Sys.hx |
| 3 |
* Copyright (C)2005-2016 Haxe Foundation |
| 4 |
* |
| 5 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 6 |
* copy of this software and associated documentation files (the "Software"), |
| 7 |
* to deal in the Software without restriction, including without limitation |
| 8 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following conditions: |
| 11 |
* |
| 12 |
* The above copyright notice and this permission notice shall be included in |
| 13 |
* all copies or substantial portions of the Software. |
| 14 |
* |
| 15 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 |
* DEALINGS IN THE SOFTWARE. |
| 22 |
*/ |
| 23 |
/** |
| 24 |
This class gives you access to many base functionalities of system platforms. Looks in `sys` sub packages for more system APIs. |
| 25 |
**/ |
| 26 |
@:require(sys) |
| 27 |
extern class Sys { |
| 28 |
|
| 29 |
/** |
| 30 |
Print any value on the standard output. |
| 31 |
**/ |
| 32 |
static function print( v : Dynamic ) : Void; |
| 33 |
|
| 34 |
/** |
| 35 |
Print any value on the standard output, followed by a newline. |
| 36 |
**/ |
| 37 |
static function println( v : Dynamic ) : Void; |
| 38 |
|
| 39 |
/** |
| 40 |
Returns all the arguments that were passed by the commandline. |
| 41 |
**/ |
| 42 |
static function args() : Array<String>; |
| 43 |
|
| 44 |
/** |
| 45 |
Returns the value of the given environment variable. |
| 46 |
**/ |
| 47 |
static function getEnv( s : String ) : String; |
| 48 |
|
| 49 |
/** |
| 50 |
Set the value of the given environment variable. |
| 51 |
**/ |
| 52 |
static function putEnv( s : String, v : String ) : Void; |
| 53 |
|
| 54 |
/** |
| 55 |
Returns the whole environement variables. |
| 56 |
**/ |
| 57 |
static function environment() : Map<String,String>; |
| 58 |
|
| 59 |
/** |
| 60 |
Suspend the current execution for the given time (in seconds). |
| 61 |
**/ |
| 62 |
static function sleep( seconds : Float ) : Void; |
| 63 |
|
| 64 |
/** |
| 65 |
Change the current time locale, which will affect `DateTools.format` date formating. |
| 66 |
Returns true if the locale was successfully changed |
| 67 |
**/ |
| 68 |
static function setTimeLocale( loc : String ) : Bool; |
| 69 |
|
| 70 |
/** |
| 71 |
Get the current working directory (usually the one in which the program was started) |
| 72 |
**/ |
| 73 |
static function getCwd() : String; |
| 74 |
|
| 75 |
/** |
| 76 |
Change the current working directory. |
| 77 |
**/ |
| 78 |
static function setCwd( s : String ) : Void; |
| 79 |
|
| 80 |
/** |
| 81 |
Returns the name of the system you are running on. For instance : |
| 82 |
"Windows", "Linux", "BSD" and "Mac" depending on your desktop OS. |
| 83 |
**/ |
| 84 |
static function systemName() : String; |
| 85 |
|
| 86 |
/** |
| 87 |
Run the given command. The command output will be printed on the same output as the current process. |
| 88 |
The current process will block until the command terminates and it will return the command result (0 if there was no error). |
| 89 |
|
| 90 |
Command arguments can be passed in two ways: 1. using `args`, 2. appending to `cmd` and leaving `args` as `null`. |
| 91 |
|
| 92 |
1. When using `args` to pass command arguments, each argument will be automatically quoted, and shell meta-characters will be escaped if needed. |
| 93 |
`cmd` should be an executable name that can be located in the `PATH` environment variable, or a path to an executable. |
| 94 |
|
| 95 |
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. |
| 96 |
It can run executables, as well as shell commands that are not executables (e.g. on Windows: `dir`, `cd`, `echo` etc). |
| 97 |
|
| 98 |
Read the `sys.io.Process` api for a more complete way to start background processes. |
| 99 |
**/ |
| 100 |
static function command( cmd : String, ?args : Array<String> ) : Int; |
| 101 |
|
| 102 |
/** |
| 103 |
Exit the current process with the given error code. |
| 104 |
**/ |
| 105 |
static function exit( code : Int ) : Void; |
| 106 |
|
| 107 |
/** |
| 108 |
Gives the most precise timestamp value (in seconds). |
| 109 |
**/ |
| 110 |
static function time() : Float; |
| 111 |
|
| 112 |
/** |
| 113 |
Gives the most precise timestamp value (in seconds) but only account for the actual time spent running on the CPU for the current thread/process. |
| 114 |
**/ |
| 115 |
static function cpuTime() : Float; |
| 116 |
|
| 117 |
/** |
| 118 |
Returns the path to the current executable that we are running. |
| 119 |
**/ |
| 120 |
@:deprecated("Use programPath instead") static function executablePath() : String; |
| 121 |
|
| 122 |
/** |
| 123 |
Returns the absolute path to the current program file that we are running. |
| 124 |
Concretely, for an executable binary, it returns the path to the binary. |
| 125 |
For a script (e.g. a PHP file), it returns the path to the script. |
| 126 |
**/ |
| 127 |
static function programPath() : String; |
| 128 |
|
| 129 |
/** |
| 130 |
Read a single input character from the standard input (without blocking) and returns it. Setting `echo` to true will also display it on the output. |
| 131 |
**/ |
| 132 |
static function getChar( echo : Bool ) : Int; |
| 133 |
|
| 134 |
/** |
| 135 |
Returns the process standard input, from which you can read what user enters. Usually it will block until the user send a full input line. See `getChar` for an alternative. |
| 136 |
**/ |
| 137 |
static function stdin() : haxe.io.Input; |
| 138 |
|
| 139 |
/** |
| 140 |
Returns the process standard output on which you can write. |
| 141 |
**/ |
| 142 |
static function stdout() : haxe.io.Output; |
| 143 |
|
| 144 |
/** |
| 145 |
Returns the process standard error on which you can write. |
| 146 |
**/ |
| 147 |
static function stderr() : haxe.io.Output; |
| 148 |
|
| 149 |
} |