Sys.hx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2005-2012, The haXe Project Contributors
  3. * All rights reserved.
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * - Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * - Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  20. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  23. * DAMAGE.
  24. */
  25. /**
  26. This class gives you access to many base functionalities of system platforms. Looks in [sys] sub packages for more system APIs.
  27. **/
  28. @:require(sys)
  29. extern class Sys {
  30. /**
  31. Print any value on the standard output.
  32. **/
  33. static function print( v : Dynamic ) : Void;
  34. /**
  35. Print any value on the standard output, followed by a newline
  36. **/
  37. static function println( v : Dynamic ) : Void;
  38. /**
  39. Returns all the arguments that were passed by the commandline.
  40. **/
  41. static function args() : Array<String>;
  42. /**
  43. Returns the value of the given environment variable.
  44. **/
  45. static function getEnv( s : String ) : String;
  46. /**
  47. Set the value of the given environment variable.
  48. **/
  49. static function putEnv( s : String, v : String ) : Void;
  50. /**
  51. Returns the whole environement variables.
  52. **/
  53. static function environment() : Hash<String>;
  54. /**
  55. Suspend the current execution for the given time (in seconds).
  56. **/
  57. static function sleep( seconds : Float ) : Void;
  58. /**
  59. Change the current time locale, which will affect [DateTools.format] date formating.
  60. Returns true if the locale was successfully changed
  61. **/
  62. static function setTimeLocale( loc : String ) : Bool;
  63. /**
  64. Get the current working directory (usually the one in which the program was started)
  65. **/
  66. static function getCwd() : String;
  67. /**
  68. Change the current working directory.
  69. **/
  70. static function setCwd( s : String ) : Void;
  71. /**
  72. Returns the name of the system you are running on. For instance :
  73. "Windows", "Linux", "BSD" and "Mac" depending on your desktop OS.
  74. **/
  75. static function systemName() : String;
  76. /**
  77. Run the given command with the list of arguments. The command output will be printed on the same output as the current process.
  78. The current process will block until the command terminates and it will return the command result (0 if there was no error).
  79. Read the [sys.io.Process] api for a more complete way to start background processes.
  80. **/
  81. static function command( cmd : String, ?args : Array<String> ) : Int;
  82. /**
  83. Exit the current process with the given error code.
  84. **/
  85. static function exit( code : Int ) : Void;
  86. /**
  87. Gives the most precise timestamp value (in seconds).
  88. **/
  89. static function time() : Float;
  90. /**
  91. 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.
  92. **/
  93. static function cpuTime() : Float;
  94. /**
  95. Returns the path to the current executable that we are running.
  96. **/
  97. static function executablePath() : String;
  98. /**
  99. 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.
  100. **/
  101. static function getChar( echo : Bool ) : Int;
  102. /**
  103. 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.
  104. **/
  105. static function stdin() : haxe.io.Input;
  106. /**
  107. Returns the process standard output on which you can write.
  108. **/
  109. static function stdout() : haxe.io.Output;
  110. /**
  111. Returns the process standard error on which you can write.
  112. **/
  113. static function stderr() : haxe.io.Output;
  114. }