Struct MemoryMappedDirectAccessor
Provides direct access to the memory-mapped file content through pointer to its virtual memory.
Inherited Members
Namespace: DotNext.IO.MemoryMappedFiles
Assembly: DotNext.Unsafe.dll
Syntax
public struct MemoryMappedDirectAccessor : IUnmanagedMemory, IDisposable, ISupplier<Stream>, IFunctional<Func<Stream>>, IFlushable
Properties
| Edit this page View SourceBytes
Represents memory-mapped file segment in the form of Span<T>.
Declaration
public readonly Span<byte> Bytes { get; }
Property Value
Type | Description |
---|---|
Span<byte> | Span<T> representing virtual memory of the mapped file segment. |
IsEmpty
Gets a value indicating that this object doesn't represent the memory-mapped file segment.
Declaration
public readonly bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
Offset
Gets the number of bytes by which the starting position of this segment is offset from the beginning of the memory-mapped file.
Declaration
public readonly long Offset { get; }
Property Value
Type | Description |
---|---|
long |
Pointer
Gets pointer to the virtual memory of the mapped file.
Declaration
public readonly Pointer<byte> Pointer { get; }
Property Value
Type | Description |
---|---|
Pointer<byte> | The pointer to the memory-mapped file. |
Size
Gets length of the mapped segment, in bytes.
Declaration
public readonly long Size { get; }
Property Value
Type | Description |
---|---|
long |
Methods
| Edit this page View SourceAsStream()
Converts the segment of the memory-mapped file.
Declaration
public readonly Stream AsStream()
Returns
Type | Description |
---|---|
Stream | The stream representing virtual memory of the memory-mapped file. |
Remarks
The caller is responsible for disposing of the returned stream.
Clear()
Sets all bits of allocated memory to zero.
Declaration
public readonly void Clear()
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory is released. |
Dispose()
Releases virtual memory associated with the mapped file segment.
Declaration
public void Dispose()
Flush()
Clears all buffers for this view and causes any buffered data to be written to the underlying file.
Declaration
public readonly void Flush()