Add memory mapped spans and streams #604
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code is originating from PDBSharp and has undergone some uncommitted/local improvements such as Write mode and Big Endian structure reading while being used in multiple side projects.
Being a separate component, it has been developed under its own code style and license (but i'm open to re-licensing or dual-licensing, as long as i can reuse the shared code).
While it could be refactored to better suit OpenSage, a possible (and attractive) alternative that i'm considering is to create a Nuget library that OpenSage (and other projects) can consume
The main feature offered here is the ability to create
Memory<byte>
, and thereforeSpan<byte>
, from aMemoryMappedFile
.This effectively enables true random access files in C# without having to use intermediate copies or buffered streams.
A subclass of
Stream
,SpanStream
, makes it possible to use this system as a drop-in replacement in some scenarios (mostly Read-only parsing, as growing ofSpanStream
is not supported).This PR currently enables this scenario for BIG files
Feel free to leave comments, suggestions or feature requests 馃檪