Ok I've found it and it was easier than I suspected:
the best thing is that there's no need to create a new class, as I suspected initially, so this way I think it would be much more easy to mantain if there's any bug there.
Function CreateSubStream:TStream(Stream:TStream, Pos:Int, Length:Int, MovePos:Int = False) Local OldPos:Int = stream.Pos() ?debug If Stream = Null Then Throw "Stream was null." End If If pos < 0 Or pos > stream.Size() Then Throw "Byte position out of bounds." End If ? Try stream.Seek(pos) Catch Err:String Throw "Stream has to be seekable." End Try Local B:TBank = CreateBank(Length) ReadBank(b, stream, 0, length) Local NewStream:TStream = OpenStream(B) If MovePos = False Then Stream.Seek(oldpos) Return newstream End Function
the best thing is that there's no need to create a new class, as I suspected initially, so this way I think it would be much more easy to mantain if there's any bug there.