public void LoadELF(string filename) { if (!System.IO.File.Exists(filename)) { throw new System.IO.FileNotFoundException(new System.IO.FileNotFoundException().Message, filename); } //The spe elf must be executable otherwise libspe will not load it if (LibspePInvoke.chmod(filename, 511 /*777 octal*/) != 0) { throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); } if (m_program != IntPtr.Zero) { LibspePInvoke.spe_image_close(m_program); } m_program = LibspePInvoke.spe_image_open(filename); if (m_program == IntPtr.Zero) { throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); } int res = LibspePInvoke.spe_program_load(m_context, m_program); if (res != 0) { throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); } }
public void Dispose() { if (m_program != IntPtr.Zero) { LibspePInvoke.spe_image_close(m_program); m_program = IntPtr.Zero; } if (m_context != IntPtr.Zero) { LibspePInvoke.spe_context_destroy(m_context); m_context = IntPtr.Zero; } }