FileOutput.hx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 sys.io;
  23. import haxe.io.Bytes;
  24. import haxe.io.Encoding;
  25. import haxe.io.Input;
  26. import haxe.io.Output;
  27. import python.io.IFileOutput;
  28. class FileOutput extends Output {
  29. var impl:IFileOutput;
  30. function new(impl:IFileOutput) {
  31. this.impl = impl;
  32. }
  33. public function seek(p:Int, pos:FileSeek):Void {
  34. return impl.seek(p, pos);
  35. }
  36. public function tell():Int {
  37. return impl.tell();
  38. }
  39. override public function set_bigEndian(b:Bool) {
  40. return impl.bigEndian = b;
  41. }
  42. override public function writeByte(c:Int):Void {
  43. impl.writeByte(c);
  44. }
  45. override public function writeBytes(s:Bytes, pos:Int, len:Int):Int {
  46. return impl.writeBytes(s, pos, len);
  47. }
  48. override public function flush():Void {
  49. impl.flush();
  50. }
  51. override public function close():Void {
  52. impl.close();
  53. }
  54. override public function write(s:Bytes):Void {
  55. impl.write(s);
  56. }
  57. override public function writeFullBytes(s:Bytes, pos:Int, len:Int):Void {
  58. impl.writeFullBytes(s, pos, len);
  59. }
  60. override public function writeFloat(x:Float):Void {
  61. impl.writeFloat(x);
  62. }
  63. override public function writeDouble(x:Float):Void {
  64. impl.writeDouble(x);
  65. }
  66. override public function writeInt8(x:Int):Void {
  67. impl.writeInt8(x);
  68. }
  69. override public function writeInt16(x:Int):Void {
  70. impl.writeInt16(x);
  71. }
  72. override public function writeUInt16(x:Int):Void {
  73. impl.writeUInt16(x);
  74. }
  75. override public function writeInt24(x:Int):Void {
  76. impl.writeInt24(x);
  77. }
  78. override public function writeUInt24(x:Int):Void {
  79. impl.writeUInt24(x);
  80. }
  81. override public function writeInt32(x:Int):Void {
  82. impl.writeInt32(x);
  83. }
  84. override public function prepare(nbytes:Int):Void {
  85. impl.prepare(nbytes);
  86. }
  87. override public function writeInput(i:Input, ?bufsize:Int):Void {
  88. impl.writeInput(i, bufsize);
  89. }
  90. override public function writeString(s:String, ?encoding:Encoding):Void {
  91. impl.writeString(s);
  92. }
  93. }