public static void SFileCloseFile(IntPtr hFile) { MpqErrorCodes status = callback_SFileCloseFile(hFile); if (status != MpqErrorCodes.Okay) { ThrowMpqException(status); } }
public static IntPtr SFileOpenArchive(string fileName, uint dwPriority, uint dwFlags) { IntPtr hMpq = IntPtr.Zero; MpqErrorCodes status = callback_SFileOpenArchive(fileName, dwPriority, dwFlags, ref hMpq); if (status != MpqErrorCodes.Okay) { ThrowMpqException(status); } return(hMpq); }
public static IntPtr SFileOpenFileEx(IntPtr hMPQ, string fileName, SearchType searchScope) { IntPtr hFile = IntPtr.Zero; MpqErrorCodes status = callback_SFileOpenFileEx(hMPQ, fileName, searchScope, ref hFile); if (status != MpqErrorCodes.Okay) { ThrowMpqException(status); } return(hFile); }
public static int SFileReadFile(IntPtr hFile, byte[] lpBuffer, int numberToRead) { int bytesRead = 0; MpqErrorCodes status = callback_SFileReadFile(hFile, lpBuffer, unchecked ((uint)numberToRead), ref bytesRead, IntPtr.Zero); if (status != MpqErrorCodes.Okay) { Debugger.Break(); ThrowMpqException(status); } return(bytesRead); }
private static void ThrowMpqException(MpqErrorCodes status) { //Console.WriteLine("Last win32 error: {0}", i); switch (status) { case MpqErrorCodes.BadOpenMode: throw new MpqException(Resources.mpq_badOpenMode); case MpqErrorCodes.FileNotFound: throw new MpqException(Resources.mpq_fileNotFound); case MpqErrorCodes.MpqInvalid: throw new MpqException(Resources.mpq_mpqArchiveCorrupt); default: throw new MpqException(string.Format(CultureInfo.InvariantCulture, Resources.mpq_UnknownErrorType, status)); } }
private static void ThrowMpqException(MpqErrorCodes status) { //Console.WriteLine("Last win32 error: {0}", i); switch (status) { case MpqErrorCodes.BadOpenMode: throw new MpqException("The MPQ file was not able to be opened in the specified mode."); case MpqErrorCodes.FileNotFound: throw new MpqException("The specified file could not be found in the MPQ archive."); case MpqErrorCodes.MpqInvalid: throw new MpqException("The MPQ file is corrupt."); default: throw new MpqException(string.Format(CultureInfo.InvariantCulture, "Unknown MPQ API error: {0}", status)); } }