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