コード例 #1
0
        public MPQFile(string fileName)
        {
            lock (mAccessLock)
            {
                FileName = fileName;

                foreach (KeyValuePair <string, IntPtr> hArchive in MPQArchiveLoader.Instance.Archives)
                {
                    bool ret = MPQArchiveLoader.SFileOpenFileEx(hArchive.Value, fileName, 0, ref fileHandle);
                    if (ret)
                    {
                        break;
                    }
                    else
                    {
                        fileHandle = IntPtr.Zero;
                    }
                }

                if (fileHandle == IntPtr.Zero)
                {
                    throw new System.IO.FileNotFoundException("No MPQ-Archive contains the file!", fileName);
                }

                Load(fileHandle);
            }
        }
コード例 #2
0
        public string[] GetFiles()
        {
            IntPtr lf  = IntPtr.Zero;
            bool   ret = MPQArchiveLoader.SFileOpenFileEx(mHandle, "(listfile)", 0, ref lf);

            if (ret == false)
            {
                return new string[] { }
            }
            ;

            MPQFile file = new MPQFile();

            file.Load(lf);
            var    bytes   = file.Read(file.FileSize);
            string fullStr = Encoding.UTF8.GetString(bytes);

            return(fullStr.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));
        }