Os.hx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C)2005-2019 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. package python.lib;
  23. import python.Exceptions.OSError;
  24. import python.Tuple;
  25. import python.Dict;
  26. extern class Stat {
  27. var st_mode:Int;
  28. var st_ino:Int;
  29. var st_dev:Int;
  30. var st_nlink:Int;
  31. var st_uid:Int;
  32. var st_gid:Int;
  33. var st_size:Int;
  34. var st_atime:Int;
  35. var st_mtime:Int;
  36. var st_ctime:Int;
  37. @:optional var st_blocks:Int;
  38. @:optional var st_blksize:Int;
  39. @:optional var st_rdev:Int;
  40. @:optional var st_flags:Int;
  41. @:optional var st_gen:Int;
  42. @:optional var st_birthtime:Int;
  43. @:optional var st_rsize:Int;
  44. @:optional var st_creator:Int;
  45. @:optional var st_type:Int;
  46. }
  47. @:pythonImport("os")
  48. extern class Os {
  49. static var environ:Dict<String, String>;
  50. static function putenv(name:String, value:String):Void;
  51. static function chdir(path:String):Void;
  52. static function unlink(path:String):Void;
  53. static function remove(path:String):Void;
  54. static function getcwd():String;
  55. static function getcwdb():Bytes;
  56. static function removedirs(path:String):Void;
  57. static function rename(src:String, dest:String):Void;
  58. static function renames(oldName:String, newName:String):Void;
  59. static function rmdir(path:String):Void;
  60. static function stat(path:String):Stat;
  61. static function fchdir(fd:FileDescriptor):Void;
  62. static function listdir(path:String = "."):Array<String>;
  63. static function walk(top:String, topdown:Bool = true, onerror:OSError->Void = null,
  64. followlinks:Bool = false):Tuple3<String, Array<String>, Array<String>>;
  65. static var sep(default, null):String;
  66. static var pathsep(default, null):String;
  67. static function makedirs(path:String, mode:Int = 511 /* Oktal 777 */, exist_ok:Bool = false):Void;
  68. static function mkdir(path:String, mode:Int = 511 /* Oktal 777 */):Void;
  69. }