static Stream GetSubStream (Stream stream)
{
#if !TARGET_JVM
if (stream is IntPtrStream)
return new IntPtrStream (stream);
#endif
if (stream is MemoryStream) {
MemoryStream other = (MemoryStream) stream;
return new MemoryStream (other.GetBuffer (), 0, (int) other.Length, false, true);
}
if (stream is TempFileStream) {
((TempFileStream) stream).SavePosition ();
return stream;
}
throw new NotSupportedException ("The stream is " + stream.GetType ());
}