Class GorgonFileSystemStream
A file stream for the Gorgon file system.
Implements
Inherited Members
Namespace: Gorgon.IO
Assembly: Gorgon.FileSystem.dll
Syntax
public class GorgonFileSystemStream : Stream, IDisposable
Constructors
| Edit this page View SourceGorgonFileSystemStream(IGorgonVirtualFile, Stream)
Initializes a new instance of the GorgonFileSystemStream class.
Declaration
protected GorgonFileSystemStream(IGorgonVirtualFile file, Stream baseStream)
Parameters
Type | Name | Description |
---|---|---|
IGorgonVirtualFile | file | File being read/written. |
Stream | baseStream | The underlying stream to use for this stream. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
Properties
| Edit this page View SourceCanRead
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceCanSeek
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceCanTimeout
Gets a value that determines whether the current stream can time out.
Declaration
public override bool CanTimeout { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceCanWrite
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceCloseUnderlyingStream
Property to set or return whether to close the underlying stream when this stream is closed.
Declaration
protected bool CloseUnderlyingStream { get; set; }
Property Value
Type | Description |
---|---|
bool |
FileEntry
Property to return the file being read/written.
Declaration
protected IGorgonVirtualFile FileEntry { get; }
Property Value
Type | Description |
---|---|
IGorgonVirtualFile |
Length
When overridden in a derived class, gets the length in bytes of the stream.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
long |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | A class derived from Stream does not support seeking. |
ObjectDisposedException | Methods were called after the stream was closed. |
Position
When overridden in a derived class, gets or sets the position within the current stream.
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
long |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support seeking. |
ObjectDisposedException | Methods were called after the stream was closed. |
ReadTimeout
Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out.
Declaration
public override int ReadTimeout { get; set; }
Property Value
Type | Description |
---|---|
int |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The ReadTimeout method always throws an InvalidOperationException. |
WriteTimeout
Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.
Declaration
public override int WriteTimeout { get; set; }
Property Value
Type | Description |
---|---|
int |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The WriteTimeout method always throws an InvalidOperationException. |
Methods
| Edit this page View SourceBeginRead(byte[], int, int, AsyncCallback, object)
Begins an asynchronous read operation.
Declaration
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The buffer to read the data into. |
int | offset | The byte offset in |
int | count | The maximum number of bytes to read. |
AsyncCallback | callback | An optional asynchronous callback, to be called when the read is complete. |
object | state | A user-provided object that distinguishes this particular asynchronous read request from other requests. |
Returns
Type | Description |
---|---|
IAsyncResult | An IAsyncResult that represents the asynchronous read, which could still be pending. |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | Attempted an asynchronous read past the end of the stream, or a disk error occurs. |
ArgumentException | One or more of the arguments is invalid. |
ObjectDisposedException | Methods were called after the stream was closed. |
NotSupportedException | The current Stream implementation does not support the read operation. |
BeginWrite(byte[], int, int, AsyncCallback, object)
Begins an asynchronous write operation.
Declaration
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The buffer to write data from. |
int | offset | The byte offset in |
int | count | The maximum number of bytes to write. |
AsyncCallback | callback | An optional asynchronous callback, to be called when the write is complete. |
object | state | A user-provided object that distinguishes this particular asynchronous write request from other requests. |
Returns
Type | Description |
---|---|
IAsyncResult | An IAsyncResult that represents the asynchronous write, which could still be pending. |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | Attempted an asynchronous write past the end of the stream, or a disk error occurs. |
ArgumentException | One or more of the arguments is invalid. |
ObjectDisposedException | Methods were called after the stream was closed. |
NotSupportedException | The current Stream implementation does not support the write operation. |
Dispose(bool)
Releases the unmanaged resources used by the Stream and optionally releases the managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
| Edit this page View SourceEndRead(IAsyncResult)
Waits for the pending asynchronous read to complete.
Declaration
public override int EndRead(IAsyncResult asyncResult)
Parameters
Type | Name | Description |
---|---|---|
IAsyncResult | asyncResult | The reference to the pending asynchronous request to finish. |
Returns
Type | Description |
---|---|
int | The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams return zero (0) only at the end of the stream, otherwise, they should block until at least one byte is available. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
IOException | The stream is closed or an internal error has occurred. |
EndWrite(IAsyncResult)
Ends an asynchronous write operation.
Declaration
public override void EndWrite(IAsyncResult asyncResult)
Parameters
Type | Name | Description |
---|---|---|
IAsyncResult | asyncResult | A reference to the outstanding asynchronous I/O request. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
IOException | The stream is closed or an internal error has occurred. |
Flush()
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Declaration
public override void Flush()
Overrides
Exceptions
Type | Condition |
---|---|
IOException | An I/O error occurs. |
Read(byte[], int, int)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | An array of bytes. When this method returns, the buffer contains the specified byte array with the values between |
int | offset | The zero-based byte offset in |
int | count | The maximum number of bytes to be read from the current stream. |
Returns
Type | Description |
---|---|
int | The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentException | The sum of |
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support reading. |
ObjectDisposedException | Methods were called after the stream was closed. |
ReadByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Declaration
public override int ReadByte()
Returns
Type | Description |
---|---|
int | The unsigned byte cast to an Int32, or -1 if at the end of the stream. |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | The stream does not support reading. |
ObjectDisposedException | Methods were called after the stream was closed. |
Seek(long, SeekOrigin)
When overridden in a derived class, sets the position within the current stream.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
long | offset | A byte offset relative to the |
SeekOrigin | origin | A value of type SeekOrigin indicating the reference point used to obtain the new position. |
Returns
Type | Description |
---|---|
long | The new position within the current stream. |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support seeking, such as if the stream is constructed from a pipe or console output. |
ObjectDisposedException | Methods were called after the stream was closed. |
SetLength(long)
When overridden in a derived class, sets the length of the current stream.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
long | value | The desired length of the current stream in bytes. |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output. |
ObjectDisposedException | Methods were called after the stream was closed. |
Write(byte[], int, int)
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | An array of bytes. This method copies |
int | offset | The zero-based byte offset in |
int | count | The number of bytes to be written to the current stream. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentException | The sum of |
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support writing. |
ObjectDisposedException | Methods were called after the stream was closed. |
WriteByte(byte)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Declaration
public override void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
byte | value | The byte to write to the stream. |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support writing, or the stream is already closed. |
ObjectDisposedException | Methods were called after the stream was closed. |