NativeTextOutput.hx 582 B

1234567891011121314151617181920212223242526272829
  1. package python.io;
  2. import haxe.io.Output;
  3. import python.io.IoTools;
  4. import python.lib.Builtin;
  5. import python.lib.io.IOBase;
  6. import python.lib.io.RawIOBase;
  7. import python.lib.io.TextIOBase;
  8. class NativeTextOutput extends NativeOutput<TextIOBase> {
  9. public function new (stream:TextIOBase) {
  10. super(stream);
  11. if (!stream.writable()) throw "Read only stream";
  12. }
  13. public function seek( p : Int, pos : sys.io.FileSeek ) : Void
  14. {
  15. IoTools.seekInTextMode(stream, tell, p, pos);
  16. }
  17. override public function writeByte(c:Int):Void
  18. {
  19. stream.write(String.fromCharCode(c));
  20. }
  21. }