示例#1
0
        // To analyze the chunkN.bin
        private void analyze(string filename)
        {
            if (!File.Exists(filename))
            {
                if (!CNMode)
                {
                    printlog("Error: file does not exist.");
                }
                else
                {
                    printlog("错误:文件不存在");
                }
                return;
            }

            try
            {
                using (BinaryReader Reader = new BinaryReader(File.Open(filename, FileMode.Open))) MagicInputFile = Reader.ReadInt32();
                if (MagicInputFile == MagicChunk)
                {
                    if (!CNMode)
                    {
                        printlog("Chunk detected,now analyzing...", true);
                    }
                    else
                    {
                        printlog("检测到chunk文件,正在解析...", true);
                    }
                    if (CombineChecked)
                    {
                        if (!CNMode)
                        {
                            printlog("Merge mode on. The program will merge all the chunk files.");
                        }
                        else
                        {
                            printlog("联合解析已开启,程序将整合所有chunkN.bin文件");
                        }
                    }
                    if (!File.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\oo2core_8_win64.dll"))
                    {
                        if (!CNMode)
                        {
                            printlog("Error: oo2core_8_win64.dll not found. Download the file from elsewhere to the executable folder.");
                        }
                        else
                        {
                            printlog("错误:未找到oo2core_8_win64.dll,请从其他地方下载该文件至本程序文件夹");
                        }
                        return;
                    }
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        CombineCheckBox.IsEnabled = false;
                    }));
                    if (CombineChecked)
                    {
                        FileInfo chosenChunkFileInfo = new FileInfo(filename);
                        string[] chunkfiles          = Directory.GetFiles(chosenChunkFileInfo.DirectoryName, "chunkG*.bin");
                        Array.Sort(chunkfiles, (a, b) => int.Parse(Regex.Replace(a, "[^0-9]", "")) - int.Parse(Regex.Replace(b, "[^0-9]", "")));
                        foreach (string filenameEach in chunkfiles)
                        {
                            Chunk cur_chunk = new Chunk();
                            itemlist = cur_chunk.AnalyzeChunk(filenameEach, this, itemlist);
                            chunkMap.Add(filenameEach, cur_chunk);
                        }
                    }
                    else
                    {
                        mainChunk = new Chunk();
                        itemlist  = mainChunk.AnalyzeChunk(filename, this, itemlist);
                    }
                    if (!CNMode)
                    {
                        printlog("Analyzation finished.");
                    }
                    else
                    {
                        printlog("解析完成");
                    }
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        this.AllowDrop       = false;
                        maingrid.AllowDrop   = false;
                        ExtractBtn.IsEnabled = true;
                        FileTree.ItemsSource = itemlist;
                    }));
                }
            }
            catch (Exception e)
            {
                if (!CNMode)
                {
                    printlog("Error info is as follows:");
                }
                else
                {
                    printlog("错误信息如下:");
                }
                printlog(e.Message);
                return;
            }
        }