Sys.hx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C)2005-2018 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. @:require(sys)
  23. @:coreApi
  24. class Sys {
  25. @:extern static public function print(v:Dynamic):Void { }
  26. @:extern static public function println(v:Dynamic):Void { }
  27. @:extern static public function args():Array<String> { return []; }
  28. @:extern static public function getEnv(s:String):String { return ""; }
  29. @:extern static public function putEnv(s:String, v:String):Void { }
  30. @:extern static public function environment():Map<String, String> { return null; }
  31. @:extern static public function sleep(seconds:Float):Void { }
  32. @:extern static public function setTimeLocale(loc:String):Bool { return false; }
  33. @:extern static public function getCwd():String { return ""; }
  34. @:extern static public function setCwd(s:String):Void { }
  35. @:extern static public function systemName():String { return ""; }
  36. @:extern static function _command(cmd:String):Int { return 0; }
  37. static public function command(cmd:String, ?args:Array<String>):Int {
  38. if (args == null) {
  39. return _command(cmd);
  40. } else {
  41. switch (systemName()) {
  42. case "Windows":
  43. cmd = [
  44. for (a in [StringTools.replace(cmd, "/", "\\")].concat(args))
  45. StringTools.quoteWinArg(a, true)
  46. ].join(" ");
  47. return _command(cmd);
  48. case _:
  49. cmd = [cmd].concat(args).map(StringTools.quoteUnixArg).join(" ");
  50. return _command(cmd);
  51. }
  52. }
  53. }
  54. static public function executablePath():String { return programPath(); }
  55. @:extern static public function exit(code:Int):Void { }
  56. @:extern static public function time():Float { return 0.; }
  57. @:extern static public function cpuTime():Float { return 0.; }
  58. @:extern static public function programPath():String { return ""; }
  59. @:extern static public function getChar(echo:Bool):Int { return 0; }
  60. @:extern static public function stdin():haxe.io.Input { return (null : sys.io.FileInput); }
  61. @:extern static public function stdout():haxe.io.Output { return (null : sys.io.FileOutput); }
  62. @:extern static public function stderr():haxe.io.Output { return (null : sys.io.FileOutput); }
  63. }