X-Git-Url: http://nitlanguage.org diff --git a/lib/filter_stream.nit b/lib/filter_stream.nit index bcd01be..4146345 100644 --- a/lib/filter_stream.nit +++ b/lib/filter_stream.nit @@ -1,6 +1,7 @@ # This file is part of NIT ( http://www.nitlanguage.org ). # # Copyright 2006 Floréal Morandat +# Copyright 2009 Jean-Sebastien Gelinas # # This file is free software, which comes along with NIT. This software is # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; @@ -13,7 +14,7 @@ class FilterIStream special IStream # Filter readed elements - readable var _stream: IStream + readable var _stream: nullable IStream redef fun eof: Bool do @@ -21,7 +22,7 @@ special IStream return stream.eof end - private fun stream=(i: IStream) + private fun stream=(i: nullable IStream) do _stream = i end @@ -30,7 +31,7 @@ end class FilterOStream special OStream # Filter outputed elements - readable var _stream: OStream + readable var _stream: nullable OStream # Can the stream be used to write redef fun is_writable: Bool @@ -62,7 +63,7 @@ special FilterIStream end end - redef fun stream: IStream + redef fun stream: nullable IStream do if _stream == null and _streams.is_ok then stream = _streams.item @@ -126,6 +127,15 @@ special FilterOStream end end + redef fun close + do + for i in _streams + do + stream = i + stream.close + end + end + init with_streams(streams: Array[OStream]) do _streams = streams