I/O Subsystem
Stream, File, Directory, BinaryReader, Compression, Hashing, and IsolatedStorage.
Component Selection
| API area | Component target | Notes |
|---|---|---|
| Streams, files, and binary I/O | SharpRuntime::IO | Core I/O surface |
| GZip and Deflate | SharpRuntime::IO.Compression | Configures ZLIB only when selected |
| ZIP archives | SharpRuntime::IO.Compression.Zip | Owns the private miniz dependency |
| Non-cryptographic hashes | SharpRuntime::IO.Hashing | Builds on the I/O component |
| Isolated storage | SharpRuntime::IO.IsolatedStorage | Uses the storage component privately |
System::IO::Stream
modules/io/include/System/IO/Stream.hpp | modules/io/src/System/IO/Stream.cpp
Abstract base class for all streams. Status: Partial
| Method | Description |
|---|---|
Read(buffer, offset, count) | Pure virtual. Read bytes into buffer. |
Close() | Close the stream. |
Length | Stream length in bytes (property). |
Position | Current position (property). |
Seek(offset, origin) | Set position relative to origin. |
Concrete Stream Types
| Class | Header | Description |
|---|---|---|
FileStream | System/IO/FileStream.hpp | File-backed stream. Read, Write, Seek. |
MemoryStream | System/IO/MemoryStream.hpp | In-memory byte buffer stream. |
BufferedStream | System/IO/BufferedStream.hpp | Buffered wrapper around another stream. |
IO::Compression::GZipStream | System/IO/Compression/GZipStream.hpp | gzip compression/decompression (ZLIB, PIMPL, 64KB buffers). |
IO::Compression::DeflateStream | System/IO/Compression/DeflateStream.hpp | Raw DEFLATE stream (-MAX_WBITS), XNB-compatible. |
IsolatedStorage::IsolatedStorageFileStream | System/IO/IsolatedStorage/IsolatedStorageFileStream.hpp | File stream within isolated storage. |
Text Readers and Writers
| Class | Header | Description |
|---|---|---|
TextReader | System/IO/TextReader.hpp | Abstract text reader |
TextWriter | System/IO/TextWriter.hpp | Abstract text writer |
StreamReader | System/IO/StreamReader.hpp | Reads text from a stream |
StreamWriter | System/IO/StreamWriter.hpp | Writes text to a stream |
StringReader | System/IO/StringReader.hpp | Reads from a string |
StringWriter | System/IO/StringWriter.hpp | Writes to a string |
Binary I/O
| Class | Header | Description |
|---|---|---|
BinaryReader | System/IO/BinaryReader.hpp | Reads primitive types from a stream in binary format |
BinaryWriter | System/IO/BinaryWriter.hpp | Writes primitive types to a stream in binary format |
File and Directory
| Class | Header | Key Methods |
|---|---|---|
File | System/IO/File.hpp | ReadAllBytes, WriteAllBytes, ReadAllText, WriteAllText, Exists, Delete, Copy, Move |
Directory | System/IO/Directory.hpp | Exists, Create, Delete, GetFiles, GetDirectories, GetCurrentDirectory |
Path | System/IO/Path.hpp | Combine, GetFileName, GetExtension, GetDirectoryName, GetFullPath |
FileInfo | System/IO/FileInfo.hpp | File metadata and operations |
DirectoryInfo | System/IO/DirectoryInfo.hpp | Directory metadata and operations |
DriveInfo | System/IO/DriveInfo.hpp | Drive information |
Compression
modules/io-compression/include/System/IO/Compression/ (GZip and Deflate) | modules/io-compression-zip/include/System/IO/Compression/ (ZIP)
| Class | Status | Description |
|---|---|---|
GZipStream | Done | gzip; backed by ZLIB; PIMPL; 64KB buffers |
DeflateStream | Done | Raw DEFLATE; -MAX_WBITS; XNB-compatible |
ZipArchive | Done | ZIP read+create; backed by miniz; PIMPL |
CompressionMode | Done | Compress / Decompress enum |
Span and Memory
modules/core/include/System/
Sharp-runtime provides the core Span<T> / Memory<T> family for zero-copy buffer slicing:
| Type | Header | Status | Description |
|---|---|---|---|
Span<T> | System/Span.hpp | Done | Non-owning mutable view over contiguous memory |
ReadOnlySpan<T> | System/ReadOnlySpan.hpp | Done | Non-owning read-only view |
Memory<T> | System/Memory.hpp | Done | Owning or borrowed heap memory slice |
ReadOnlyMemory<T> | System/ReadOnlyMemory.hpp | Done | Read-only memory slice |
MemoryExtensions | System/MemoryExtensions.hpp | Done | AsSpan, ContainsAny, IndexOf/LastIndexOf, BinarySearch, Trim, Overlaps… |
SpanSplitEnumerator | System/SpanSplitEnumerator.hpp | Done | Iterates span split on delimiter |
#include <System/Span.hpp>
#include <System/MemoryExtensions.hpp>
std::vector<int> data = {1, 2, 3, 4, 5};
System::Span<int> span(data.data(), data.size());
auto slice = span.Slice(1, 3); // {2, 3, 4}
Hashing
modules/io-hashing/include/System/IO/Hashing/
| Class | Status | Description |
|---|---|---|
XxHash32 | Done | xxHash 32-bit non-cryptographic hash |
XxHash64 | Done | xxHash 64-bit non-cryptographic hash |
Crc32 | Done | CRC-32 non-cryptographic hash |
NonCryptographicHashAlgorithm | Done | Base class |
RandomAccess
modules/io/include/System/IO/RandomAccess.hpp | modules/io/src/System/IO/RandomAccess.cpp
Status: Done — but POSIX-only on Linux/macOS.
Uses pread/pwrite/fsync on POSIX, and Win32 OVERLAPPED ReadFile/WriteFile on Windows. Emscripten throws PlatformNotSupportedException.
IsolatedStorage
modules/io-isolated-storage/include/System/IO/IsolatedStorage/
Provides sandboxed file storage. The storage root is determined by SharpRuntime::Storage::StoragePaths::GetIsolatedStorageRoot().
| Class | Status |
|---|---|
IsolatedStorageFile | Partial |
IsolatedStorageFileStream | Partial |
IsolatedStorageException | Done |
Platform Notes
System::IO::RandomAccess— usespread/pwrite; POSIX-only (has Win32 fallback)- Network streams — see Platform Layer