/// <summary> /// Constructs a new IOSystem. /// </summary> public IOSystem() { m_openProc = OnAiFileOpenProc; m_closeProc = OnAiFileCloseProc; AiFileIO fileIO; fileIO.OpenProc = Marshal.GetFunctionPointerForDelegate(m_openProc); fileIO.CloseProc = Marshal.GetFunctionPointerForDelegate(m_closeProc); fileIO.UserData = IntPtr.Zero; m_fileIOPtr = MemoryHelper.AllocateMemory(MemoryHelper.SizeOf<AiFileIO>()); Marshal.StructureToPtr(fileIO, m_fileIOPtr, false); m_openedFiles = new Dictionary<IntPtr, IOStream>(); }
/// <summary> /// Constructs a new IOSystem. /// </summary> public IOSystem() { m_openProc = OnAiFileOpenProc; m_closeProc = OnAiFileCloseProc; AiFileIO fileIO; fileIO.OpenProc = Marshal.GetFunctionPointerForDelegate(m_openProc); fileIO.CloseProc = Marshal.GetFunctionPointerForDelegate(m_closeProc); fileIO.UserData = IntPtr.Zero; m_fileIOPtr = MemoryHelper.AllocateMemory(MemoryHelper.SizeOf <AiFileIO>()); Marshal.StructureToPtr(fileIO, m_fileIOPtr, false); m_openedFiles = new Dictionary <IntPtr, IOStream>(); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing">True to release both managed and unmanaged resources; False to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_isDisposed) { if (m_fileIOPtr != IntPtr.Zero) { MemoryHelper.FreeMemory(m_fileIOPtr); m_fileIOPtr = IntPtr.Zero; } if (disposing) { m_openProc = null; m_closeProc = null; CloseAllFiles(); } m_isDisposed = true; } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing">True to release both managed and unmanaged resources; False to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if(!m_isDisposed) { if(m_fileIOPtr != IntPtr.Zero) { MemoryHelper.FreeMemory(m_fileIOPtr); m_fileIOPtr = IntPtr.Zero; } if(disposing) { m_openProc = null; m_closeProc = null; CloseAllFiles(); } m_isDisposed = true; } }