Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory mapped spans and streams #604

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

smx-smx
Copy link

@smx-smx smx-smx commented Sep 15, 2021

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 therefore Span<byte>, from a MemoryMappedFile.
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 of SpanStream is not supported).

This PR currently enables this scenario for BIG files

Feel free to leave comments, suggestions or feature requests 馃檪

@smx-smx smx-smx marked this pull request as ready for review October 30, 2021 21:45
@smx-smx
Copy link
Author

smx-smx commented Oct 30, 2021

Nuget package published, and BIG files are implemented (both R/W supported).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant