Class IOStream
Defines a stream to some file input or output source. This object is responsible for reading/writing data that is used by Assimp.
Implements
Inherited Members
Namespace: SharpAssimp
Assembly: SharpAssimp.dll
Syntax
public abstract class IOStream : IDisposable
Constructors
| Edit this page View SourceIOStream(string, FileIOMode)
Constructs a new IOStream.
Declaration
public IOStream(string pathToFile, FileIOMode fileMode)
Parameters
Type | Name | Description |
---|---|---|
string | pathToFile | Path to file given by Assimp |
FileIOMode | fileMode | Desired file access mode |
IOStream(string, FileIOMode, bool)
Constructs a new IOStream.
Declaration
protected IOStream(string pathToFile, FileIOMode fileMode, bool initialize = true)
Parameters
Type | Name | Description |
---|---|---|
string | pathToFile | Path to file given by Assimp |
FileIOMode | fileMode | Desired file access mode |
bool | initialize | True if initialize should be immediately called with the default callbacks. Set this to false if your subclass requires a different way to setup the function pointers. |
Properties
| Edit this page View SourceFileMode
Gets the original desired file access mode.
Declaration
public FileIOMode FileMode { get; }
Property Value
Type | Description |
---|---|
FileIOMode |
IsDisposed
Gets whether or not this IOStream has been disposed.
Declaration
public bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
bool |
IsValid
Gets whether the stream is in fact valid - that is, the input/output has been properly located and can be read/written.
Declaration
public abstract bool IsValid { get; }
Property Value
Type | Description |
---|---|
bool |
PathToFile
Gets the original path to file given by Assimp.
Declaration
public string PathToFile { get; }
Property Value
Type | Description |
---|---|
string |
Methods
| Edit this page View SourceClose()
Closes the stream - flushing any data not yet read/written and disposes of resources.
Declaration
public virtual void Close()
Dispose()
Disposes of resources held by the IOStream.
Declaration
public void Dispose()
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | True to release both managed and unmanaged resources; False to release only unmanaged resources. |
~IOStream()
Finalizes an instance of the IOStream class.
Declaration
protected ~IOStream()
Flush()
Flushes all data currently in the stream buffers.
Declaration
public abstract void Flush()
GetFileSize()
Gets the total file size (in bytes).
Declaration
public abstract long GetFileSize()
Returns
Type | Description |
---|---|
long | File size in bytes |
GetPosition()
Gets the current file position pointer (in bytes).
Declaration
public abstract long GetPosition()
Returns
Type | Description |
---|---|
long | Current file position pointer (in bytes) |
Initialize(AiFileWriteProc, AiFileReadProc, AiFileTellProc, AiFileTellProc, AiFileSeek, AiFileFlushProc, nint)
Initializes the system by setting up native pointers for Assimp to the specified functions. A reference to each supplied callback is held on to avoid it being GC'ed.
Declaration
protected void Initialize(AiFileWriteProc aiFileWriteProc, AiFileReadProc aiFileReadProc, AiFileTellProc aiFileTellProc, AiFileTellProc aiFileSizeProc, AiFileSeek aiFileSeek, AiFileFlushProc aiFileFlushProc, nint userData = 0)
Parameters
Type | Name | Description |
---|---|---|
AiFileWriteProc | aiFileWriteProc | Handles write requests. |
AiFileReadProc | aiFileReadProc | Handles read requests. |
AiFileTellProc | aiFileTellProc | Handles tell requests. |
AiFileTellProc | aiFileSizeProc | Handles size requests. |
AiFileSeek | aiFileSeek | Handles seek requests. |
AiFileFlushProc | aiFileFlushProc | Handles flush requests. |
nint | userData | Additional user data, if any. |
OnAiFileFlushProc(nint)
Callback for Assimp that handles flushes.
Declaration
protected void OnAiFileFlushProc(nint file)
Parameters
Type | Name | Description |
---|---|---|
nint | file |
OnAiFileReadProc(nint, nint, nuint, nuint)
Callback for Assimp that handles reads.
Declaration
protected nuint OnAiFileReadProc(nint file, nint dataRead, nuint sizeOfElemInBytes, nuint numElements)
Parameters
Type | Name | Description |
---|---|---|
nint | file | |
nint | dataRead | |
nuint | sizeOfElemInBytes | |
nuint | numElements |
Returns
Type | Description |
---|---|
nuint |
OnAiFileSeekProc(nint, nuint, Origin)
Callback for Assimp that handles seeks.
Declaration
protected ReturnCode OnAiFileSeekProc(nint file, nuint offset, Origin seekOrigin)
Parameters
Type | Name | Description |
---|---|---|
nint | file | |
nuint | offset | |
Origin | seekOrigin |
Returns
Type | Description |
---|---|
ReturnCode |
OnAiFileSizeProc(nint)
Callback for Assimp that handles size requests.
Declaration
protected nuint OnAiFileSizeProc(nint file)
Parameters
Type | Name | Description |
---|---|---|
nint | file |
Returns
Type | Description |
---|---|
nuint |
OnAiFileTellProc(nint)
Callback for Assimp that handles tell requests.
Declaration
protected nuint OnAiFileTellProc(nint file)
Parameters
Type | Name | Description |
---|---|---|
nint | file |
Returns
Type | Description |
---|---|
nuint |
OnAiFileWriteProc(nint, nint, nuint, nuint)
Callback for Assimp that handles writes.
Declaration
protected nuint OnAiFileWriteProc(nint file, nint dataToWrite, nuint sizeOfElemInBytes, nuint numElements)
Parameters
Type | Name | Description |
---|---|---|
nint | file | |
nint | dataToWrite | |
nuint | sizeOfElemInBytes | |
nuint | numElements |
Returns
Type | Description |
---|---|
nuint |
Read(byte[], long)
Reads data from the stream.
Declaration
public abstract long Read(byte[] dataRead, long count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | dataRead | Byte buffer to store the read data in |
long | count | Number of bytes to read |
Returns
Type | Description |
---|---|
long | Number of bytes actually read. Should be equal to the specified count, unless if EoF was hit or an error occured. |
Seek(long, Origin)
Sets the current file position pointer.
Declaration
public abstract ReturnCode Seek(long offset, Origin seekOrigin)
Parameters
Type | Name | Description |
---|---|---|
long | offset | Offset in bytes from the origin |
Origin | seekOrigin | Origin reference |
Returns
Type | Description |
---|---|
ReturnCode | ReturnCode indicating success or failure. |
Write(byte[], long)
Writes data to the stream.
Declaration
public abstract long Write(byte[] dataToWrite, long count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | dataToWrite | Data to write |
long | count | Number of bytes to write |
Returns
Type | Description |
---|---|
long | Number of bytes actually written. Should be equal to the specified count, unless if EoF was hit or an error occured. |