SubstreamSharp 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SubstreamSharp --version 1.0.2                
NuGet\Install-Package SubstreamSharp -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SubstreamSharp" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SubstreamSharp --version 1.0.2                
#r "nuget: SubstreamSharp, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SubstreamSharp as a Cake Addin
#addin nuget:?package=SubstreamSharp&version=1.0.2

// Install SubstreamSharp as a Cake Tool
#tool nuget:?package=SubstreamSharp&version=1.0.2                

Icon

SubstreamSharp

SubstreamSharp is a C# library that provides the ability to create substreams of fixed regions from any given stream.

Overview

A substream is effectively a region of the underlying stream with a fixed position and offset that behaves as an independent stream. A substream supports all the operations that the underlying stream does, however only within the context of specific region.

The main usage is the ability to provide callers with a portion of a stream that might be backed by a larger stream, for instance a large uncompressed binary file stream that may have individual files within its contents exposed as substreams.

Examples

Creating a substream from a file stream starting from offset 128 for the following 1024 bytes:

using SubstreamSharp;

using (var fileStream = new FileStream("file", FileMode.Open))
{
	var substream = new Substream(fileStream, 128L, 1024L);
}
using SubstreamSharp;

using (var fileStream = new FileStream("file", FileMode.Open))
{
	var substream = fileStream.Substream(128L, 1024L);
}

Notes

Substreams work by explicitly seeking the underlying stream to the correct position before any read or write operation takes place. This does mean that the underlying stream will have an undefined position if it is used by itself again after a substream has been created from it. Therefore, it is important to Seek on the underlying stream if it is being used in parallel to any substreams.

Any substream will not permit operations that would potentially modify the data outside of its region. For instance, attempting to seek backwards before the start of the substream, or attempting to seek forwards after the end of the substream. A substream can also not have its length modified.

Since a substream is designed to be merely a chunk of an underlying stream, closing a substream will not close the underlying stream. Likewise, closing the underlying stream will inadvertendly close any substreams. Therefore, there is no need to manually call the Close or Dispose methods on a substream.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SubstreamSharp:

Package Downloads
SpelunkyWad

SpelunkyWad is a C# library for reading and writing Spelunky WAD and WIX files.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on SubstreamSharp:

Repository Stars
MeltyPlayer/FinModelUtility
Model viewer and command-line tools for extracting models from various GCN/3DS/PC games en-masse.
Version Downloads Last updated
1.0.3 22,129 12/26/2021
1.0.2 803 12/17/2021
1.0.1 719 12/12/2021