kaitai_struct_cpp_stl_runtime icon indicating copy to clipboard operation
kaitai_struct_cpp_stl_runtime copied to clipboard

Why doesn't `kstream::close()` close the underlying `std::istream`?

Open generalmimon opened this issue 3 years ago • 1 comments

@GreyCat Is there a reason m_io->close() is commented out here?

https://github.com/kaitai-io/kaitai_struct_cpp_stl_runtime/blob/cb09b3a84c7e905c6a3fecfe9617cf864d9af781/kaitai/kaitaistream.cpp#L44-L46

This "implementation" comes from the initial commit in 2016 when the C++/STL runtime was started (8d533f3:kaitai/kaitaistream.cpp:8), so perhaps it was disabled just for debugging reasons during the initial testing, but I don't see any reason why kstream::close() should be a no-op - makes no sense to me.

generalmimon avatar Feb 26 '22 16:02 generalmimon

m_io has type std::istream, which is defined as std::basic_istream<char>. I see that std::basic_istream is an abstract class that doesn't have any close() method, so it's no surprise that it can't be called.

If kaitai::kstream::close() is impossible to implement, it should be removed, otherwise it looks like the runtime library is capable of something it in fact isn't.

This is, of course, a potential breaking change, but I think for the better.

generalmimon avatar Mar 17 '22 16:03 generalmimon