예제 #1
0
        public static void SFileCloseFile(IntPtr hFile)
        {
            MpqErrorCodes status = callback_SFileCloseFile(hFile);

            if (status != MpqErrorCodes.Okay)
            {
                ThrowMpqException(status);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
 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));
     }
 }
예제 #6
0
 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));
     }
 }
예제 #7
0
        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));
            }
        }
예제 #8
0
        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));
            }
        }