|
@@ -31,16 +31,22 @@ class NativeInput extends Input
|
|
public var canSeek(get_canSeek, null):Bool;
|
|
public var canSeek(get_canSeek, null):Bool;
|
|
|
|
|
|
var stream:cs.system.io.Stream;
|
|
var stream:cs.system.io.Stream;
|
|
|
|
+ var _eof:Bool;
|
|
|
|
+
|
|
public function new(stream)
|
|
public function new(stream)
|
|
{
|
|
{
|
|
this.stream = stream;
|
|
this.stream = stream;
|
|
|
|
+ this._eof = false;
|
|
if (!stream.CanRead) throw "Write-only stream";
|
|
if (!stream.CanRead) throw "Write-only stream";
|
|
}
|
|
}
|
|
|
|
|
|
override public function readByte():Int
|
|
override public function readByte():Int
|
|
{
|
|
{
|
|
var ret = stream.ReadByte();
|
|
var ret = stream.ReadByte();
|
|
- if (ret == -1) throw new Eof();
|
|
|
|
|
|
+ if (ret == -1) {
|
|
|
|
+ _eof = true;
|
|
|
|
+ throw new Eof();
|
|
|
|
+ }
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -49,8 +55,10 @@ class NativeInput extends Input
|
|
if( pos < 0 || len < 0 || pos + len > s.length )
|
|
if( pos < 0 || len < 0 || pos + len > s.length )
|
|
throw Error.OutsideBounds;
|
|
throw Error.OutsideBounds;
|
|
var ret = stream.Read(s.getData(), pos, len);
|
|
var ret = stream.Read(s.getData(), pos, len);
|
|
- if (ret == 0)
|
|
|
|
|
|
+ if (ret == 0) {
|
|
|
|
+ _eof = true;
|
|
throw new Eof();
|
|
throw new Eof();
|
|
|
|
+ }
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -66,6 +74,7 @@ class NativeInput extends Input
|
|
|
|
|
|
public function seek( p : Int, pos : sys.io.FileSeek ) : Void
|
|
public function seek( p : Int, pos : sys.io.FileSeek ) : Void
|
|
{
|
|
{
|
|
|
|
+ _eof = false;
|
|
var pos = switch(pos)
|
|
var pos = switch(pos)
|
|
{
|
|
{
|
|
case SeekBegin: cs.system.io.SeekOrigin.Begin;
|
|
case SeekBegin: cs.system.io.SeekOrigin.Begin;
|
|
@@ -81,8 +90,8 @@ class NativeInput extends Input
|
|
return cast(stream.Position, Int);
|
|
return cast(stream.Position, Int);
|
|
}
|
|
}
|
|
|
|
|
|
- public function eof() : Bool
|
|
|
|
|
|
+ public inline function eof() : Bool
|
|
{
|
|
{
|
|
- return stream.Position == stream.Length;
|
|
|
|
|
|
+ return _eof;
|
|
}
|
|
}
|
|
}
|
|
}
|