A step towards RAII for hsStream. This makes streams much easier to manage correctly, especially when using std::unique_ptr, collections and such.
In fact, I removed hsStream::Close entirely, because almost nothing closed a stream without destroying it soon afterwards. Sometimes this was done to reuse a single stream object for multiple files, but it's not hard to recreate the stream for each file instead.
This isn't "proper full RAII", because opening a stream is still its own method call and not part of the constructor. I wasn't sure how to handle error reporting and virtual Open calls if the constructor does the opening. This isn't a big problem though I think - the automatic closing is the important part.
The diff is long, but it's mostly boring deleting of all the manual Close calls. The actually interesting changes are in hsStream and its implementations. The updated logic in plRegistryNode, plStreamSource, and pfPatcher could use some extra eyes perhaps.
A step towards RAII for
hsStream
. This makes streams much easier to manage correctly, especially when usingstd::unique_ptr
, collections and such.In fact, I removed
hsStream::Close
entirely, because almost nothing closed a stream without destroying it soon afterwards. Sometimes this was done to reuse a single stream object for multiple files, but it's not hard to recreate the stream for each file instead.This isn't "proper full RAII", because opening a stream is still its own method call and not part of the constructor. I wasn't sure how to handle error reporting and virtual
Open
calls if the constructor does the opening. This isn't a big problem though I think - the automatic closing is the important part.The diff is long, but it's mostly boring deleting of all the manual
Close
calls. The actually interesting changes are inhsStream
and its implementations. The updated logic in plRegistryNode, plStreamSource, and pfPatcher could use some extra eyes perhaps.