示例#1
0
        void ReOpen()
        {
            if (jumpArc != null)
            {
                jumpArc.Close();
            }

            try
            {
                jumpArc = new JumpArchive();
                jumpArc.Open(System.IO.Directory.GetCurrentDirectory() + "\\Data.jmp");
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("data.jmp不存在,请确认补丁程序是否放置到300英雄目录");
                Application.Exit();
            }
            catch (JumpArchive.InvalidPackageException)
            {
                MessageBox.Show("无效的文件包");
                Application.Exit();
            }
            catch (IOException)
            {
                MessageBox.Show("Data.jmp文件被占用,请确认是否开启了300英雄或补丁程序.");
                Application.Exit();
            }
            catch (Exception ex)
            {
                MessageBox.Show("未知错误" + ex.ToString());

                Application.Exit();
            }
        }
示例#2
0
        private void rebuildFilePackage()
        {
            try
            {
                string newFile = System.IO.Directory.GetCurrentDirectory() + "\\Data2.jmp";

                JumpArchive.FileHeaderMarshal header = new JumpArchive.FileHeaderMarshal();
                header.fileCount = (uint)jumpArc.files.Count;
                header.hdr       = "DATA1.0".PadRight(50, '\0').ToCharArray();
                int structSize = Marshal.SizeOf(new JumpArchive.FileEntryMarshal());
                int headerSize = Marshal.SizeOf(new JumpArchive.FileHeaderMarshal());
                int dataStart  = jumpArc.files.Count * structSize + headerSize;
                JumpArchive.FileEntryMarshal[] file_list = new JumpArchive.FileEntryMarshal[jumpArc.files.Count];
                int    i = 0;
                byte[] temp;
                Log("开始重建数据文件....");
                using (FileStream outputStream = File.Open(newFile, FileMode.Create))
                {
                    outputStream.Seek(dataStart, SeekOrigin.Begin);
                    Log("处理文件数据....");
                    foreach (var node in jumpArc.files)
                    {
                        file_list[i].filename     = node.Value.filename.PadRight(260, '\0').ToCharArray();
                        file_list[i].compressSize = node.Value.compressSize;
                        file_list[i].sourceSize   = node.Value.sourceSize;
                        file_list[i].reserved     = new byte[0x20];
                        file_list[i].offset       = (uint)outputStream.Position;
                        jumpArc.dataFileStream.Seek(node.Value.offset, SeekOrigin.Begin);
                        temp = new byte[node.Value.compressSize];
                        jumpArc.dataFileStream.Read(temp, 0, (int)node.Value.compressSize);
                        outputStream.Write(temp, 0, (int)node.Value.compressSize);
                        i++;
                    }

                    Log("处理文件头信息....");
                    outputStream.Seek(0, SeekOrigin.Begin);
                    byte[] headerBytes = JumpArchive.StructToBytes(header);
                    outputStream.Write(headerBytes, 0, headerBytes.Length);

                    for (i = 0; i < jumpArc.files.Count; i++)
                    {
                        outputStream.Seek(headerSize + (structSize * i), SeekOrigin.Begin);
                        temp = JumpArchive.StructToBytes(file_list[i]);
                        outputStream.Write(temp, 0, temp.Length);
                    }

                    outputStream.Flush();
                    Log("重建完成....");
                }

                this.jumpArc.Close();
                this.jumpArc = null;
                File.Delete(System.IO.Directory.GetCurrentDirectory() + "\\Data.jmp");
                File.Move(System.IO.Directory.GetCurrentDirectory() + "\\Data2.jmp", System.IO.Directory.GetCurrentDirectory() + "\\Data.jmp");

                ReOpen();
                BeginInvoke(new rebuildCompleteDelegate(rebuildComplete));
            }
            catch (Exception ex)
            {
                MessageBox.Show("未知错误" + ex.ToString());
            }
        }